@dmytromykhailiuk/react-di-module
v1.0.6
Published
A way to connect Dependency Injection Container to React application
Downloads
7
Readme
React Dependency Injection Module
A way to connect Dependency Injection Container to React applications
(This package is using @dmytromykhailiuk/dependency-injection-container package)
Installation
npm i @dmytromykhailiuk/react-di-module
Interesting packages
- Dependency Injection Container
- React Dependency Injection Module
- RxJS React Redux Effects
- Condition Flow Engine
Example of usage
import { Module, useInject, useObservable } from '@dmytromykhailiuk/react-di-module';
const providers = [
// ...
UserStoreFacade,
// ...
];
function App() {
return (
<Module providers={providers}>
<UsersComponent/>
</Module>
);
}
function UsersComponent() {
const userStoreFacade = useInject<UserStoreFacade>(UserStoreFacade);
const users = useObservable<User[]>(userStoreFacade.users$);
return // ... render users
}