UNPKG

788 BTypeScriptView Raw
1import type { Dispatch, SetStateAction } from 'react';
2declare const s: unique symbol;
3type S = typeof s;
4export type Control<T> = {[s]: T};
5
6type Nullish = null | undefined;
7
8export function useControl<S>(control: Control<S> | Nullish, initial: S | (() => S)): [S, Dispatch<SetStateAction<S>>, Control<S>];
9export function useControl<S>(control: Control<S>): [S, Dispatch<SetStateAction<S>>, Control<S>];
10export function useControl<S = undefined>(control: Control<S> | Nullish): [S | undefined, Dispatch<SetStateAction<S | undefined>>, Control<S>];
11
12type State<S> = [S, Dispatch<SetStateAction<S>>];
13export function useThru<S>(control: Control<S> | Nullish, interceptor: (state: State<S>) => State<S>): Control<S>;
14
15export function isControl(maybeControl): maybeControl is Control<any>;