State management via explicit actions, for when useState stops being enough.
useReducer(reducer, initialState) mirrors the core pattern behind Redux in a single hook: a pure function taking the current state and a dispatched action, returning the next state. It becomes the clearer choice over useState once state updates get complex — several related pieces of state that change together, or transitions that depend heavily on the previous state and which action fired, rather than a single independent value.
The reducer itself must stay pure — no side effects, no mutating the existing state object, always returning a new state value. Unlike a setter closure created fresh each render, the dispatch function's identity is stable across re-renders, which makes it safe to pass down to deeply nested children or into a dependency array without it triggering unnecessary re-runs.
What you'll walk away knowing