14 lines
952 B
TypeScript
14 lines
952 B
TypeScript
import type { Ref, Context, ComponentChild } from './preact';
|
|
|
|
export type StateUpdater<S> = S | ((prevState: S) => S);
|
|
export function useState<S>(initialState: S | (() => S)): [S, (update: StateUpdater<S>) => void];
|
|
export function useReducer<S, A>(reducer: (state: S, action: A) => S, initialState: S): [S, (action: A) => void];
|
|
export function useEffect(effect: () => void | (() => void), inputs?: readonly unknown[]): void;
|
|
export function useLayoutEffect(effect: () => void | (() => void), inputs?: readonly unknown[]): void;
|
|
export function useRef<T>(initialValue: T): { current: T };
|
|
export function useRef<T>(initialValue: T | null): Ref<T>;
|
|
export function useRef<T = undefined>(): Ref<T | undefined>;
|
|
export function useMemo<T>(factory: () => T, inputs: readonly unknown[]): T;
|
|
export function useCallback<T extends (...args: any[]) => any>(callback: T, inputs: readonly unknown[]): T;
|
|
export function useContext<T>(context: Context<T>): T;
|