useReducer<StateT, ActionT> function

Store<StateT, ActionT> useReducer<StateT, ActionT>(
  1. Reducer<StateT, ActionT> reducer, {
  2. required StateT initialState,
  3. required ActionT initialAction,
})

An alternative to useState for more complex states.

useReducer manages a read only instance of state that can be updated by dispatching actions which are interpreted by a Reducer.

reducer is immediately called on first build with initialAction and initialState as parameter.

It is possible to change the reducer by calling useReducer with a new Reducer.

See also:

Implementation

Store<StateT, ActionT> useReducer<StateT, ActionT>(
  Reducer<StateT, ActionT> reducer, {
  required StateT initialState,
  required ActionT initialAction,
}) {
  return use(
    _ReducerHook(
      reducer,
      initialAction: initialAction,
      initialState: initialState,
    ),
  );
}