Skip to content

Instantly share code, notes, and snippets.

@coryhouse
Last active June 11, 2017 19:41
Show Gist options
  • Save coryhouse/f31ab2ca81ca45195a4e4889cade0e11 to your computer and use it in GitHub Desktop.
Save coryhouse/f31ab2ca81ca45195a4e4889cade0e11 to your computer and use it in GitHub Desktop.
Handling immutable state in React with immutability-helper
// Import at the top:
import update from 'immutability-helper';
updateState({target}) {
let user = update(this.state.user, {$merge: {[target.name]: target.value}});
this.setState({user});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment