React patterns: When to use useReducer over useState
23 October 2022 (Updated 23 October 2022)
Consider using useReducer
when you have multiple state pieces that often change together or when updating one state depends on reading the value of another state.
A reducer helps centralize how multiple related state slices are updated in response to user actions or events which usually makes your UI easier to reason about.
Tagged:
React patterns
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment