freestyler-context
v1.3.6
Published
React context provider and consumer HOC and FaCC
Downloads
55
Readme
freestyler-context
Generic context provider/consumer library for React.
Usage:
import {Provider, Consumer} from 'freestyler-context';
<Provider name="theme" value={{color: 'red'}}>
<Consumer name="theme">{(theme) => {
return <div>Color is: {theme.color}</div>;
}}</Consumer>
</Provider>
Merges values of multiple providers with the same name:
import {Provider, Consumer} from 'freestyler-context';
<Provider name="theme" value={{color: 'red', background: '#fff'}}>
<Provider name="theme" value={{color: 'blue'}}>
<Consumer name="theme">{(theme) => {
return <div>Color is: {theme.color}</div>;
}}</Consumer>
</Provider>
</Provider>