UNPKG

context-state

Version:
25 lines (22 loc) 890 B
import * as react from 'react'; import { PropsWithChildren } from 'react'; import { UseHookType, EqualityFn, Middleware, SelectorFn } from './types.js'; declare function createStore<Value, InitialValue>(useHook: UseHookType<InitialValue, Value>, options?: { /** * @description Same as React.memo's second argument * Compare the current and next state to determine whether an update should be re-rendered * @default shallowEqual */ eq?: EqualityFn; /** * @description Middleware for store */ middlewares?: Middleware<Value>[]; }): { useStore: { <Selected extends keyof Value>(selector?: Selected[]): Pick<Value, Selected>; <Selected>(selector?: SelectorFn<Value, Selected>, eqFn?: EqualityFn<Selected>): Selected; }; Provider: react.NamedExoticComponent<PropsWithChildren<InitialValue>>; }; export { createStore };