Inversify Props
This package is a wrapper of inversify-props to simplify how inject your dependencies in components with hooks.
Installation
npm install --save inversify-hooks
Usage
container.addSingleton<IService1>(Service1);
container.addSingleton<IService2>(Service2);
function ExampleComponent() {
const service1 = useService<IService1>('IService1');
}
Why we made this package
You can learn more about why we made this packages in the original repo.
How register a dependency
If you're not familizared of how to register dependencies, check the docs.
How to use in your components
Once your dependencies are registered in the container, is simple use the hook to get the dependency.
function ExampleComponent() {
const service1 = useService<IService1>('IService1');
}
How to configure uglify
If you're using uglify or similar you need to configure well the plugin.
Next steps
- Remove id param, and use
magic if
like in inversify-props.