import { SetStateAction } from 'react'; /** * [state, startTransition, endTransition, currentTransition] * * @typeParam S state type * @typeParam T state transition type */ export type TransitioningState = readonly [ /** * state */ S, /** * startTransition * * Queue the given state transition with the given transition type * * Analog of React setState * * @param nextState a React setState action for this state (either a literal value or function (prev) => next) * @param transition if defined, is set as the currentTransition; nextState is queued and will not be completed until endTransition is called * If null, completes all interim transitions, then the given nextState transition and rerenders the using component */ (nextState: SetStateAction, transition: T | null) => void, /** * endTransition * * calling completes all queued transitions in order, sets currentTransition to null, and rerenders */ () => void, /** * currentTransition, null if not currently transitioning */ T | null ]; declare function useTransitioningState(): TransitioningState; /** * State is always a defined S if an initial state is provided */ declare function useTransitioningState(initialState: S, initialTransition?: T | null): TransitioningState; declare function useTransitioningState(initialState: S | undefined, initialTransition?: T | null): TransitioningState; export default useTransitioningState;