useUndoRedo
Maintain state history and navigation.
useUndoRedo.tsx
import { useUndoRedo } from "@cermuel/hooks/react";export function useUndoRedoExample() { const history = useUndoRedo('draft'); return <button type="button" onClick={history.undo}>Undo</button>;}Props
Param
Type
Default Value
initialValueTlimit?number100Returns
{ value: T; set: (next: T) => void; history: T[]; index: number; canUndo: boolean; canRedo: boolean; undo: () => void; redo: () => void; reset: (next?: T) => void; }