Skip to content

useStateHistory ​

utilities
test coverage
Last changed: last month

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

NameTypeDefaultNote
initialValueValue-- The initial value to start the history with
maxSize?number10- Maximum number of history entries to keep

Source ​

Source • Demo

Contributors ​

Avatardebabin

Released under the MIT License.