@anandarizki/use-undo-redo
Version: 
A hook provides a simple and efficient way to manage undo and redo functionality in your React applications
23 lines (22 loc) • 509 B
TypeScript
type Options = {
    capacity?: number;
    debounce?: number;
};
type Output<T> = [
    () => void,
    () => void,
    {
        canUndo: boolean;
        canRedo: boolean;
        reset: () => void;
        history: StateHistory<T>[];
        jumpTo: (pointer: number) => void;
        pointer: number;
    }
];
type StateHistory<T> = {
    value: T;
    timestamp: Date;
};
export declare function useUndoRedo<T>(primaryState: [T, (v: T) => void], { capacity, debounce }?: Options): Output<T>;
export {};