Skip to content

Hook useHistory()

useHistory<Type>(initialState: Type): { history: Type[]; pushState: (state: Type) => void; redo: () => void; redoAvailable: boolean; stateIndex: number; undo: () => void; undoAvailable: boolean; }

Source: history.ts

Returns an object that handles stateful history with undo and redo methods

Type Parameters

Type

Type

Parameters

initialState

Type

Returns

history

history: Type[]

The entries of the history

pushState()

pushState: (state: Type) => void

Adds a new entry to the history

Parameters

state

Type

Returns

void

redo()

redo: () => void

Moves forwards in the history

Returns

void

redoAvailable

redoAvailable: boolean

stateIndex

stateIndex: number

The index of the active entry in list of entries

undo()

undo: () => void

Moves backwards in the history

Returns

void

undoAvailable

undoAvailable: boolean

Built by Prozilla