Skip to content

Instantly share code, notes, and snippets.

@Jahans3
Last active December 16, 2018 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jahans3/0e61c2a960be5a39038c30ab0baea7a9 to your computer and use it in GitHub Desktop.
Save Jahans3/0e61c2a960be5a39038c30ab0baea7a9 to your computer and use it in GitHub Desktop.
Updating our state
export class StateProvider extends Component {
static defaultProps = {
state: {}
};
state = this.props.state;
render () {
return (
<Provider value={{ state: this.state, setState: this.setState.bind(this) }}>
{this.props.children}
</Provider>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment