Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
inversify-hooks
Advanced tools
Wrapper of inversify-props to inject your dependencies in the components, made with TypeScript using hooks.
This package is a wrapper of inversify-props to simplify how inject your dependencies in components with hooks.
$ npm install inversify-hooks reflect-metadata --save
The inversify-hooks type definitions are included in the inversify-hooks npm package.
import 'reflect-metadata'; // Import only once
import { container, useInject } from 'inversify-hooks';
container.addSingleton<IService1>(Service1);
function ExampleComponent() {
const [service1] = useInject<IService1>(cid.IService1);
useEffect(() => {
if (!service1) {
return;
}
service1.asyncMethod();
}, [])
}
container.addSingleton<IService1>(Service1, 'MyService1');
function ExampleComponent() {
const service1 = useInject<IService1>('MyService1');
}
:warning: Important! inversify-hooks requires TypeScript >= 2.0 and the
experimentalDecorators
,emitDecoratorMetadata
,types
andlib
compilation options in yourtsconfig.json
file.
{
"compilerOptions": {
"target": "es5",
"lib": ["es6"],
"types": ["reflect-metadata"],
"module": "commonjs",
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}
There are more examples of how to use the container in services or other components in inversify-props
You can learn more about why we made this packages in the original repo.
If you're not familizared of how to register dependencies, check the docs.
f you're using Uglify or Terser you need to configure well the plugin, check the docs.
FAQs
Wrapper of inversify-props to inject your dependencies in the components, made with TypeScript using hooks.
The npm package inversify-hooks receives a total of 779 weekly downloads. As such, inversify-hooks popularity was classified as not popular.
We found that inversify-hooks demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.