UNPKG

zustand-utils

Version:
26 lines (25 loc) 863 B
import type { ReactNode } from 'react'; import type { StoreApi } from 'zustand'; export declare type UseContextStore<S extends StoreApi<unknown>> = { (): ExtractState<S>; <U>(selector: (state: ExtractState<S>) => U, equalityFn?: (a: U, b: U) => boolean): U; }; declare type ExtractState<S> = S extends { getState: () => infer T; } ? T : never; declare type WithoutCallSignature<T> = { [K in keyof T]: T[K]; }; /** * create context for individual App * mostly use for component */ export declare const createContext: <S extends StoreApi<unknown>>() => { Provider: ({ createStore, children }: { createStore: () => S; children: any; }) => import("react").FunctionComponentElement<import("react").ProviderProps<S | undefined>>; useStore: UseContextStore<S>; useStoreApi: () => WithoutCallSignature<S>; }; export {};