Last active
May 24, 2018 07:30
-
-
Save coryhouse/7fb17dd8a49287a3154d7947bee83647 to your computer and use it in GitHub Desktop.
Using object spread to handle immutable state in React
This file contains hidden or 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
updateState(event) { | |
const {name, value} = event.target; | |
let user = {...this.state.user, [name]: value}; | |
this.setState({user}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment