Gathering detailed insights and metrics for ioc
Gathering detailed insights and metrics for ioc
Gathering detailed insights and metrics for ioc
Gathering detailed insights and metrics for ioc
npm install ioc
Typescript
Module System
Node Version
NPM Version
66.4
Supply Chain
93.5
Quality
74.9
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
15,890
Last Day
1
Last Week
60
Last Month
197
Last Year
1,379
MIT License
17 Stars
26 Commits
2 Forks
2 Watchers
16 Branches
1 Contributors
Updated on Jun 28, 2023
Minified
Minified + Gzipped
Latest Version
2.1.1
Package Id
ioc@2.1.1
Unpacked Size
23.73 kB
Size
5.76 kB
File Count
11
NPM Version
5.6.0
Node Version
8.11.3
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
30.4%
60
Compared to previous week
Last Month
-1.5%
197
Compared to previous month
Last Year
-32.9%
1,379
Compared to previous year
3
25
IoC library for React, with support for NextJS
Notice of change of ownership: Starting version 1.0.0 this package has changed it's owner and goals. Previous version (0.1.0) is still available on npm via npm install ioc@0.1.0
. Thank you.
* Expects to be installed alongside React
yarn:
1$ yarn add ioc
npm:
1$ npm install --save ioc
Add provider at the top of your React app:
App.js
1import React from 'react'; 2import { provide, types } from 'ioc'; 3import SharedComponent1 from './components/SharedComponent1'; 4import SharedLibrary from './lib/SharedLibrary'; 5 6@provide({ 7 @types.func.isRequired 8 SharedComponent1, 9 10 @types.object 11 SharedLibrary 12}) 13export default class App extends React.Component { 14 15 constructor(props) { 16 super(props); 17 this.state = { ...state }; 18 } 19 20 render() { 21 return ( 22 // the app 23 ); 24 } 25}
Add consumer at the individual components:
node_modules/@my-components/SomeGenericComponent.js
1import React from 'react'; 2import { inject, PropTypes } from 'ioc'; 3 4@inject({ 5 SharedComponent1: PropTypes.func.isRequired 6}) 7export default class extends React.Component { 8 render() { 9 const { SharedComponent1 } = this.props; 10 11 return ( 12 <div> 13 Showing stuff: 14 <SharedComponent1 some={} props={}> 15 <a>Link Text</a> 16 </SharedComponent1> 17 </div> 18 ); 19 } 20}
Next.js example could be found in their examples repository.
Individual component testing is pretty simple, just provide your dependencies as props
and add .dive()
step to your shallow render, as with any High Order Component.
1import { shallow } from 'enzyme'; 2import React from 'react'; 3import renderer from 'react-test-renderer'; 4 5import Component from './components/Component'; 6 7describe('With Enzyme', () => { 8 it('Component renders with props', () => { 9 // no need to SharedComponent1 Link component much for shallow rendering 10 const injected = shallow(<Component SharedComponent1={() => {}} />); 11 const component = injected.dive(); 12 expect(component.find('h1').text()).toEqual('My Component'); 13 expect(component.find('SharedComponent1').find('a').text()).toEqual('Link Text'); 14 }); 15}); 16 17describe('With Snapshot Testing', () => { 18 it('Component renders with props', () => { 19 const component = renderer.create(<Component SharedComponent1={(props) => <div comment="mocked SharedComponent1 component">{props.children}</div>} />); 20 const tree = component.toJSON(); 21 expect(tree).toMatchSnapshot(); 22 }); 23});
For more details check out tests.
IoC is released under the MIT license.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/12 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
64 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More