https://ko.react.dev/reference/react/useReducer#usereducer

useReducer is a React Hook that lets you add a reducer to your component.

Reference

useReducer(reducer, initialArg, init?)

Parameteres

Returns

useReducer returns an array with exactly two values: The current state.

  1. During the first render, it’s set to init(initialArg) or initialArg (if there’s no init).
  2. The dispatch function
    1. that lets you update the state to a different value and trigger a re-render.

Caveats

dispatch function

The dispatch function returned by useReducer lets you update the state to a different value and trigger a re-render. You need to pass the action as the only argument to the dispatch function: