Reducers visual mental model
A reducer turns current state + action โ next state.
Current state
the existing snapshot
Action
describes what happened
reducer(state, action)
Next state
a new snapshot React can render from
Actions describe events, reducers decide transitionsโ
Action
{'{ type: "itemAdded", item }'} says what happened.
Reducer
decides how that event changes the state model.
Reducers stay pureโ
Inside reducer
calculate next state ยท validate transitions ยท update immutable structures
Outside reducer
network calls ยท analytics ยท timers ยท DOM APIs ยท random external effects
When a reducer helpsโ
Does this state need a reducer?
One or two simple independent values?useState is often clearer
Many related transitions?Reducer can centralize them
Transitions are naturally event/action driven?Reducer is a strong fit
Need transition logic tested independently?Reducer helps
Problem is remote caching or subscription granularity?Reducer alone is not the solution
Reducer + Contextโ
Feature Provider
owns useReducer
State Context
read current feature state
Dispatch Context
send actions to the owner
Feature UI A
Feature UI B
Feature UI C
The debugging advantageโ
User / system event
Reducer transition
Next state
UI renders from state
This makes it easier to ask: what action happened, what state existed, and what transition produced the result?
Continue with useReducer and Reducer Design and Reducer with Context for implementation details, TypeScript patterns, and production architecture.