Created
December 11, 2018 17:30
-
-
Save itzsaga/e9c02bb76b5e10f4d8e2e2c101b5cf7f to your computer and use it in GitHub Desktop.
Updating React nested state.
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
this.setState(prevState => ({ | |
...prevState, | |
someProperty: { | |
...prevState.someProperty, | |
someOtherProperty: { | |
...prevState.someProperty.someOtherProperty, | |
anotherProperty: { | |
...prevState.someProperty.someOtherProperty.anotherProperty, | |
flag: false | |
} | |
} | |
} | |
})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment