Skip to content

Instantly share code, notes, and snippets.

@darklilium
Last active May 2, 2017 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darklilium/f3f33abb86ee6612b491bfe14f928677 to your computer and use it in GitHub Desktop.
Save darklilium/f3f33abb86ee6612b491bfe14f928677 to your computer and use it in GitHub Desktop.
Edit state for a certain attr in an object.
//Ex: We have this var in a state in react.
var obj = {
obs: "hello",
id: 1
}
...
//To modify "obs" we do:
this.setState({
obj: update(this.state.obj, {obs: {$set: "byebye"} })
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment