Hooks

Reducer function

Compute the next state from the preceding state and a dispatched event without side effects.

Formal Syntax & Structure

react syntaxreact
function reducer(state, action) { /* return next state */ }

Working Example

Example Snippetreact
return {...state, seats: state.seats + 1};
React Reference