Skip to content

Instantly share code, notes, and snippets.

@ma-9
Created February 28, 2020 07:43
Show Gist options
  • Save ma-9/1935aab58d5b9938d1dfd467ba20c23a to your computer and use it in GitHub Desktop.
Save ma-9/1935aab58d5b9938d1dfd467ba20c23a to your computer and use it in GitHub Desktop.
Update State in Functional Component with PrevState
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