reducer
A pure function that takes the current state and an action and returns the next state.
In more detail
Reducers must not start timers, make network calls or change their inputs; they only calculate. Because all transitions live in one place, a reducer is easy to test and to read as a list of what can happen.
Related terms
- useReducer — The React hook that manages state through a reducer function, returning the current state and a dispatch function.
- reducer action — A plain object describing something that happened, usually with a type string and optional payload data, sent to a reducer through dispatch.
- pure function — A function whose result depends only on its arguments and which has no side effects, so the same inputs always give the same output.
Taught in
- Complex State with useReducer: State Machines And Action Types — React 19 & Modern Component Architecture
- useOptimistic: Instantaneous UI Updates with Rollback — React 19 & Modern Component Architecture