useReducer()
useReducer()
useReducer – React 繁體中文
集中State的更新處理
使用Action和Reducer更新State
[state, dispatch] = useReducer(reducer, initialState)
Reducer:
(currentState, action) => newState