@supunlakmal/hooks
Version:
A collection of reusable React hooks
17 lines (16 loc) • 898 B
TypeScript
import { type Dispatch } from 'react';
import { type NextState } from '../../util/resolve-hook-state';
type MediatedStateResult<State> = [State, Dispatch<NextState<State>>];
type MediatedStateResultWithUndefined<State = undefined> = [
State | undefined,
Dispatch<NextState<State | undefined>>
];
type MediatedStateResultWithMediator<State, RawState> = [
State,
Dispatch<NextState<RawState, State>>
];
export type InitialState<State> = State | (() => State);
export declare function useMediatedState<State = undefined>(): MediatedStateResultWithUndefined<State>;
export declare function useMediatedState<State>(initialState: InitialState<State>): MediatedStateResult<State>;
export declare function useMediatedState<State, RawState = State>(initialState: InitialState<State>, mediator: (rawNextState: RawState) => State): MediatedStateResultWithMediator<State, RawState>;
export {};