UNPKG

@keislamoglu/react-conditional

Version:

Reduce the complexity of conditional rendering.

20 lines (19 loc) 602 B
export declare type Conditional<T> = { doAction: (action: T) => void; undoAction: (action: T) => void; clearActions: () => void; setActions: (actions: T[]) => void; verifyCondition: (when: When<T>) => boolean; }; export declare type When<ActionType> = { done: ActionType[]; undone?: ActionType[]; } | { done?: ActionType[]; undone: ActionType[]; } | null; export declare type TeardownFn = () => unknown; export declare type HandlerFn = () => TeardownFn | void; export declare type Condition<T> = { verifyAndPerform: (actions: T[]) => void; };