Last active
May 2, 2017 18:45
-
-
Save darklilium/f3f33abb86ee6612b491bfe14f928677 to your computer and use it in GitHub Desktop.
Edit state for a certain attr in an object.
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
//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