UNPKG

constate

Version:

Yet another React state management library that lets you work with local state and scale up to global state with ease

11 lines (10 loc) 765 B
import * as React from "react"; //#region src/index.d.ts type Selector<Value> = (value: Value) => any; type SelectorHooks<Selectors> = { [K in keyof Selectors]: () => Selectors[K] extends ((...args: any) => infer R) ? R : never }; type Hooks<Value, Selectors extends Selector<Value>[]> = Selectors["length"] extends 0 ? [() => Value] : SelectorHooks<Selectors>; type ConstateTuple<Props, Value, Selectors extends Selector<Value>[]> = [React.FC<React.PropsWithChildren<Props>>, ...Hooks<Value, Selectors>]; declare function constate<Props, Value, Selectors extends Selector<Value>[]>(useValue: (props: Props) => Value, ...selectors: Selectors): ConstateTuple<Props, Value, Selectors>; //#endregion export { constate as default }; //# sourceMappingURL=index.d.ts.map