0
2
JRJose Romero
reacthookuseReducerβ’β’β’
React TypeScript RecipesAn alternative to useState. Accepts a reducer of type (state, action) => newState, and returns the current state paired with a dispatch method. (If youβre familiar with Redux, you already know how this works.)
Library: react
Shortcut: react.hook.reducer.use
import { useReducer } from "react";
const [state, dispatch] = useReducer(reducer, initialArg, init);