UNPKG

react-use

Version:
15 lines (14 loc) 697 B
import { Dispatch } from 'react'; import { InitialHookState, ResolvableHookState } from './util/resolveHookState'; interface HistoryState<S> { history: S[]; position: number; capacity: number; back: (amount?: number) => void; forward: (amount?: number) => void; go: (position: number) => void; } export declare type UseStateHistoryReturn<S> = [S, Dispatch<ResolvableHookState<S>>, HistoryState<S>]; export declare function useStateWithHistory<S, I extends S>(initialState: InitialHookState<S>, capacity?: number, initialHistory?: I[]): UseStateHistoryReturn<S>; export declare function useStateWithHistory<S = undefined>(): UseStateHistoryReturn<S | undefined>; export {};