Socket
Socket
Sign inDemoInstall

inversify-hooks

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inversify-hooks - npm Package Compare versions

Comparing version 1.3.2 to 1.3.6

4

package.json
{
"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).

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc