Creates a custom hook for managing state with reducers (similar to Redux Toolkit).
The state type.
The reducer map type.
The reducer configuration (initialState, reducers).
A custom hook.
Uses Immer for immutable state updates. Returns a hook that provides the state and action dispatchers.
const useCounter = createReducerHook({ initialState: { count: 0 }, reducers: { increment: (state) => { state.count += 1; } }});const [state, { increment }] = useCounter(); Copy
const useCounter = createReducerHook({ initialState: { count: 0 }, reducers: { increment: (state) => { state.count += 1; } }});const [state, { increment }] = useCounter();
Creates a custom hook for managing state with reducers (similar to Redux Toolkit).