inversify-hooks
Advanced tools
Comparing version 1.3.2 to 1.3.6
{ | ||
"name": "inversify-hooks", | ||
"version": "1.3.2", | ||
"version": "1.3.6", | ||
"description": "Wrapper of inversify-props to inject your dependencies in the components, made with TypeScript using hooks.", | ||
@@ -26,4 +26,4 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"inversify-props": "^1.3.0" | ||
"inversify-props": "^1.3.6" | ||
} | ||
} |
@@ -19,2 +19,27 @@ # Inversify Hooks | ||
## How to use | ||
``` | ||
import 'reflect-metadata'; // Import only once | ||
import { container, useContainer } from 'inversify-hooks'; | ||
container.addSingleton<IService1>(Service1); | ||
function ExampleComponent() { | ||
const service1 = useContainer<IService1>(cid.IService1); | ||
useEffect(() => { | ||
service1.asyncMethod(); | ||
}, []) | ||
} | ||
``` | ||
## You can also use any ID that you prefer | ||
``` | ||
container.addSingleton<IService1>(Service1, 'MyService1'); | ||
function ExampleComponent() { | ||
const service1 = useContainer<IService1>('MyService1'); | ||
} | ||
``` | ||
> :warning: **Important!** inversify-hooks requires TypeScript >= 2.0 and the `experimentalDecorators`, `emitDecoratorMetadata`, `types` and `lib` | ||
@@ -35,21 +60,7 @@ compilation options in your `tsconfig.json` file. | ||
} | ||
## Usage | ||
``` | ||
container.addSingleton<IService1>(Service1); | ||
function ExampleComponent() { | ||
const service1 = useContainer<IService1>(cid.IService1); | ||
} | ||
``` | ||
## More examples | ||
There are more examples of how to use the container in services or other components in [inversify-props](https://github.com/ckgrafico/inversify-props#how-to-use) | ||
## 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 | ||
@@ -56,0 +67,0 @@ You can learn more about why we made this packages in the [original repo](https://github.com/ckgrafico/inversify-props#why-we-made-this-package). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6558
72
Updatedinversify-props@^1.3.6