Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
boxed-injector-react
Advanced tools
Dependency Injection Tools for React Applications
$ npm install --save boxed-injector-react
This is a set of helper components for leveraging the boxed-injector within a React application.
The use case for this is to pull business logic out of your components into separate testable services, and inject them into your components as props so that you can use them in multiple places. Leveraging a DI container enables automatic dependency resolution greatly simplifying application bootstrapping while making your code more declarative.
There are 2 main components.
$ npm install --save boxed-injector-react
Somewhere in app bootstrapping land, leverage the commonjs module cache to gain access to a singleton of inject and register your stuff.
// injector.config.js
const React = require('React');
const Injector = require('boxed-injector').Injector;
const Inject = require('boxed-injector-react')(React).Inject;
const types = {
FOO: 'FOO'
};
let inject;
function injectorConfig () {
const injector = new Injector();
injector.register(types.FOO, 'foo');
inject = new Inject(injector);
return injector;
};
injectorConfig.inject = inject;
injectorConfig.types = types;
module.exports = injectorConfig;
Then, in your components, reference the singleton to gain access to the injector.
// MyComponent.js
const React = require('React');
const inject = require('./injector.config').inject;
@inject({ 'baz': 'foo' })
class MyComponent extends React.Component {
render(){
console.log(this.props);
return <div/>;
}
}
We look forward to seeing your contributions!
MIT © Ben Lugavere
FAQs
Dependency Injection Tools for React
We found that boxed-injector-react demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.