UNPKG

common-hook

Version:
10 lines (9 loc) 488 B
type SetState<S extends Record<string, any>> = <K extends keyof S>(state: Pick<S, K> | null | ((prevState: Readonly<S>) => Pick<S, K> | S | null)) => void; /** * @name 管理 object 类型 state 的 Hooks * @description 用法与 class 组件的 this.setState 基本一致 * @example * const [state, setState] = useSetState<State>({hello: '',count: 0}) */ export declare const useSetState: <S extends Record<string, any>>(initialState: S | (() => S)) => [S, SetState<S>]; export {};