react-context-subscriber
A Higher-order-Component for subscribing to the new React Context. This will make the context available in the lifecycle methods etc.
Installation
yarn add react-context-subscriber
Usage
This doesn't actual need to be the new React Context. It will work with any Consumer that accepts a function as it's child. For example this will work with react-create-context too.
;; // Again, this doesn't need to be the new React Contextconst Context = React; Component { return thispropscontext; } ContextConsumerComponent;
Change the prop name of the context
Simply pass to the HoC a string as the second argument.
The default prop name is context
.
;; // Again, this doesn't need to be the new React Contextconst Context = React; Component { return thispropscontext; } ContextConsumer 'propName'Component;
License
MIT