mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-22 11:52:00 +00:00
Include where setState is comming from (#3652)
Co-authored-by: Sebastian Silbermann <silbermann.sebastian@gmail.com>
This commit is contained in:
@@ -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};
|
||||
|
||||
Reference in New Issue
Block a user