UNPKG

react-use-object-state

Version:

React hooks to create stateful API's for reusable object patterns

18 lines (17 loc) 678 B
import { Dispatch, SetStateAction } from "react"; export declare type ArrayStateFactory<T> = { clear: VoidFunction; reverse: VoidFunction; pop: VoidFunction; push: (...val: T[]) => void; shift: VoidFunction; unshift: (...val: T[]) => void; insertAt: (val: T, index: number) => void; upsertAt: (val: T, index: number) => void; deleteAt: (index: number) => void; }; export declare const arrayStateFactory: <T>(setState: Dispatch<SetStateAction<T[]>>) => ArrayStateFactory<T>; export declare const useArrayState: <T>(initialState: T[]) => ArrayStateFactory<T> & { state: T[]; setState: Dispatch<SetStateAction<T[]>>; };