Inversify Hooks
This package is a wrapper of inversify-props to simplify how inject your dependencies in components with hooks.
Installation
npm install --save inversify-hooks reflect-metadata@0.1.12
Usage
container.addSingleton<IService1>(Service1);
function ExampleComponent() {
const service1 = useContainer<IService1>(cid.IService1);
}
You can also use any ID that you prefer
container.addSingleton<IService1>(Service1, 'MyService1');
function ExampleComponent() {
const service1 = useContainer<IService1>('MyService1');
}
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 configure Uglify or Terser
f you're using Uglify or Terser you need to configure well the plugin, check the docs.