Instantly share code, notes, and snippets.

@Jahans3 Jahans3/update-state.js
Last active Dec 16, 2018

Embed
What would you like to do?
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