UNPKG

@supunlakmal/hooks

Version:

A collection of reusable React hooks

13 lines (12 loc) 736 B
import { type SetStateAction } from 'react'; type StateInitializerFN<State> = () => State; type StateUpdaterFN<State, PreviousState = State> = (previousState: PreviousState) => State; export type InitialState<State> = State | StateInitializerFN<State>; export type NextState<State, PreviousState = State> = State | StateUpdaterFN<State, PreviousState>; export type ControlledRerenderDispatch<A> = (value: A, rerender?: boolean) => void; /** * Like `React.useState`, but its state setter accepts extra argument, that allows to cancel * rerender. */ export declare const useControlledRerenderState: <S = undefined>(initialState?: S | (() => S)) => [S | undefined, ControlledRerenderDispatch<SetStateAction<S | undefined>>]; export {};