dispatch function
The function returned by useReducer that sends an action to the reducer and schedules a re-render with the result.
In more detail
React guarantees the dispatch function keeps the same identity for the life of the component, so it can be passed to children or context without memoization and without causing re-renders. You call it from event handlers, never during rendering.
Example
dispatch({ type: "FETCH_START" })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.
- reference equality — Comparing two references to see whether they point to the very same object, rather than to objects with equal contents.
Taught in
- Component Purity: Pure Functions, Idempotence And Side Effects — React 19 & Modern Component Architecture
- State with useState: Immutability And Asynchronous Batching — React 19 & Modern Component Architecture
- Complex State with useReducer: State Machines And Action Types — React 19 & Modern Component Architecture
- SyntheticEvent System: Event Delegation in Modern React — React 19 & Modern Component Architecture
- useRef Mechanics: DOM References And Mutable Persistent State — React 19 & Modern Component Architecture
- useContext in Depth: Scoping, Consumer Subscription Costs — React 19 & Modern Component Architecture
- Custom Hook Composition: Encapsulating Reactive Logic — React 19 & Modern Component Architecture
- Creating Event Listener Hooks with Clean Teardown Logic — React 19 & Modern Component Architecture
- useTransition: Non-Blocking State Updates for Fluid UI — React 19 & Modern Component Architecture
- useOptimistic: Instantaneous UI Updates with Rollback — React 19 & Modern Component Architecture