Beta

useUndoRedo

React hook to undo and redo actions.

Made by lucas

Installation

Usage

const { state, set, undo, redo, reset, canUndo, canRedo } = useUndoRedo<string>(
  { initialValue: "" },
);

const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
  set(e.target.value);
};

return (
  <div>
    <Input value={state} onChange={handleChange} />
  </div>
);

Props

PropTypeDefault
initialValue
string
-
maxHistory?
number
-