useStateHistory ​
Hook that manages state with history functionality
typescript
import { useStateHistory } from '@siberiacancode/reactuse';
Usage ​
typescript
const { value, history, index, set, back, forward, reset, undo } = useStateHistory(0);
Demo ​
Api ​
Parameters
Name | Type | Default | Note |
---|---|---|---|
initialValue | Value | - | - The initial value to start the history with |
maxSize? | number | 10 | - Maximum number of history entries to keep |