Last active
September 30, 2019 14:41
-
-
Save Palatnyi/53865ab5bf4a375d2b35c9187b74caf3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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