unstated-subscribe-hoc
Use Unstated's
<Subscribe />
component as a higher-order component.
Install
yarn add unstated-subscribe-hoc
npm i unstated-subscribe-hoc
Usage
const SubscribedReactComponent =
Example
const Example = <div className=displaystatehideExample && 'hide'> cartstateitemslength itemcartstateitemslength === 1 ? '' : 's' in your cart </div> // Subscribe Example to CartContainer (prop 'cart') and DisplayContainer (prop 'display')Example cart: CartContainer display: DisplayContainer
Works with defined instances of Container
also:
const cart = items: 'A super nice shirt' Example cart display: DisplayContainer
Why?
I found myself passing in the containers as props anyway and I figured I'd make a shortcut for it.
Credits
This is a very small module that could not be made possible without James Kyle's Unstated.
License
MIT © James Anthony Bruno