Hooks

useReducer

Connect a component to a pure state transition function; optionally compute initial state from an input.

Formal Syntax & Structure

react syntaxreact
const [state, dispatch] = useReducer(reducer, initialArg, init);

Working Example

Example Snippetreact
const [count, dispatch] = useReducer(seatReducer, 0);
React Reference