ioc
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.
Install
* Expects to be installed alongside React
yarn:
$ yarn add ioc
npm:
$ npm install --save ioc
Usage
Add provider at the top of your React app:
App.js
;;;; @Component { superprops; thisstate = ...state ; } { return // the app ; }
Add consumer at the individual components:
node_modules/@my-components/SomeGenericComponent.js
;; @Component { const SharedComponent1 = thisprops; return <div> Showing stuff: <SharedComponent1 some={} props={}> <a>Link Text</a> </SharedComponent1> </div> ; }
Next.js
Next.js example could be found in their examples repository.
Testing
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.
;;; ; ; ;
For more details check out tests.
License
IoC is released under the MIT license.