# react-dididi

> A simple DI/IoC lib for react.

Latest version **1.0.2** (published 2021-10-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-dididi
pnpm add react-dididi
yarn add react-dididi
bun add react-dididi
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2021-10-22 |
| First published | 2021-10-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 12.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | willx12123 |
| Maintainers | willx12123 |

## Links

- npm: https://www.npmjs.com/package/react-dididi
- npm.io page: https://npm.io/package/react-dididi

## Dependencies (1)

- [react](https://npm.io/package/react.md) ^17.0.2

## Recent versions

- 1.0.2 (latest) — 2021-10-22
- 1.0.1 — 2021-10-21
- 1.0.0 — 2021-10-21

## README

# react-dididi

A simple DI/IoC lib for react.

## Install

```bash
npm install react-dididi
```

## Use

```ts
import { Injectable } from "react-dididi";

@Injectable()
export class FooService {
  constructor(private readonly barService: BarService) {}

  print() {
    this.barService.name;
  }
}

@Injectable()
export class BarService {
  name = "Andy";
}

```

```ts
// main.ts

import { setProvides } from "react-dididi";

import { FooService, BarService } from "xxxx";

setProvides([FooService, BarService]);

```

```tsx
import { useInject } from "react-dididi";

const xx: React.FC = () => {
  const fooService = useInject(FooService);

  useEffect(() => {
    fooService.print();
  }, []);
};
```

---
_Source: https://npm.io/package/react-dididi · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
