Skip to content

Instantly share code, notes, and snippets.

@ohansemmanuel
Last active April 13, 2019 09:47
Show Gist options
  • Save ohansemmanuel/6e14372f4e2e458031eecb66e4688473 to your computer and use it in GitHub Desktop.
Save ohansemmanuel/6e14372f4e2e458031eecb66e4688473 to your computer and use it in GitHub Desktop.
// 🐢 setState (object merge) vs useState (object replace)
// assume initial state is {name: "Ohans"}
setState({ age: 'unknown' })
// new state object will be
// {name: "Ohans", age: "unknown"}
useStateUpdater({ age: 'unknown' })
// new state object will be
// {age: "unknown"} - initial object is replaced
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment