Instantly share code, notes, and snippets.

Embed
What would you like to do?
Our context's provider
import React, { Component, createContext } from 'react';
const { Provider, Consumer } = createContext();
export const StateConsumer = Consumer;
export class StateProvider extends Component {
static defaultProps = {
state: {}
};
state = this.props.state;
render () {
return (
<Provider value={this.state}>
{this.props.children}
</Provider>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment