Skip to content

Commit

Permalink
fix: typo in 02.state-optimization/README.mdx
Browse files Browse the repository at this point in the history
Fix bug where `setState` does not return a new state.
  • Loading branch information
jsparkdev authored Mar 30, 2024
1 parent 5512042 commit 9fb56a3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions exercises/02.state-optimization/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ const [state, setState] = useState({ count: 0 })

// ...
setState({ count: 0 }) // <-- will trigger a rerender
setState(previousState => {
setState(previousState => ({
count: previousState.count
}) // <-- will trigger a rerender
})) // <-- will trigger a rerender
setState(previousState => previousState) // <-- will not trigger a rerender
```

Expand Down

0 comments on commit 9fb56a3

Please sign in to comment.