Skip to content

Instantly share code, notes, and snippets.

@coryhouse
Last active May 24, 2018 07:30
Show Gist options
  • Save coryhouse/7fb17dd8a49287a3154d7947bee83647 to your computer and use it in GitHub Desktop.
Save coryhouse/7fb17dd8a49287a3154d7947bee83647 to your computer and use it in GitHub Desktop.
Using object spread to handle immutable state in React
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