Browse Source

Include where `setState` is comming from (#3652)

Co-authored-by: Sebastian Silbermann <silbermann.sebastian@gmail.com>
main
m019m1 4 years ago
committed by GitHub
parent
commit
5119600cf6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      content/docs/hooks-reference.md

1
content/docs/hooks-reference.md

@ -76,6 +76,7 @@ If your update function returns the exact same value as the current state, the s
> Unlike the `setState` method found in class components, `useState` does not automatically merge update objects. You can replicate this behavior by combining the function updater form with object spread syntax:
>
> ```js
> const [state, setState] = useState({});
> setState(prevState => {
> // Object.assign would also work
> return {...prevState, ...updatedValues};

Loading…
Cancel
Save