Created
February 28, 2020 07:43
-
-
Save ma-9/1935aab58d5b9938d1dfd467ba20c23a to your computer and use it in GitHub Desktop.
Update State in Functional Component with PrevState
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
onChange={e => { | |
const val = e.target.value; | |
setMessage(prevState => { | |
return { ...prevState, message: val } | |
}); | |
}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment