Update based on previous state safely.
Section: State Hooks
useState updater function
tsx
tsx
setCount(prev => prev + 1);Explanation
Prefer the updater form when the next state depends on the previous state.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing State Hooks