type StateType = {
open: boolean;
};
type ActionType = Partial<StateType>;
const initialState = { open: false };
function countReducer(prevState: StateType, action: ActionType) {
return { ...prevState, ...action } ;
}
const [state, dispatch] = useReducer(countReducer, initialState);
typescript useReducer定义类型
于 2024-06-17 16:40:30 首次发布