useReducer(reducer, initialState) centralises state transitions in a pure function (state, action) => newState. Prefer it over several useState calls when: the next state depends on the previous one in non-trivial ways, many event handlers update the same data, you want the logic testable without rendering anything. Anatomy Reducers must be pure: no API calls, no mutations, no randomness — return a new object instead. Name actions after what happened ("added", "toggled") rather than what to set.
Key Takeaways
useReducer moves update logic into a pure, testable function.
Dispatch actions that describe what happened.
Never mutate state in a reducer — return new objects.
Combine useReducer with Context for a lightweight global store.