use-reduction
Version:
Simplify your reducer hooks
14 lines • 433 B
TypeScript
import { Reducer } from "react";
declare type Action<T, P> = {
type: T;
payload: P;
};
declare type ActionMap<A> = {
[K in keyof A]: (payload?: A[K]) => void;
};
declare type ReducerMap<S, A> = {
[K in keyof A]: Reducer<S, Action<K, A[K]>>;
};
export default function useReduction<S, A>(initialState: S, reducerMap: ReducerMap<S, A>, debug?: boolean): [S, ActionMap<A>];
export {};
//# sourceMappingURL=index.d.ts.map