useReducer passes current state and an action to a reducer, then renders from the returned next state. Keeping related transition rules in one function makes multiple event paths easier to inspect.
The demo sends add, complete, and reset actions through a task state. A reducer should return new state without mutating the previous one; handle asynchronous work in an event handler or effect.
When to use
Use it when many event types change one state and its transition rules become hard to follow.