Skip to content

Instantly share code, notes, and snippets.

@Palatnyi
Last active September 30, 2019 14:41
Show Gist options
  • Save Palatnyi/53865ab5bf4a375d2b35c9187b74caf3 to your computer and use it in GitHub Desktop.
Save Palatnyi/53865ab5bf4a375d2b35c9187b74caf3 to your computer and use it in GitHub Desktop.
class Store extends Component {
constructor(props) {
super(props);
this.rootUpdater = (data = {}) => {
this.setState({
...this.state,
...data
})
};
this.getState = () => {
return {...this.state};
};
const user = new User(this.getState, this.rootUpdater);
this.state = {user};
}
render() {
return (
<Context.Provider value={this.state}>
{this.props.children}
</Context.Provider>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment