Some checks failed
CI/CD Pipeline / unit-tests (push) Failing after 1m16s
CI/CD Pipeline / integration-tests (push) Failing after 2m32s
CI/CD Pipeline / lint (push) Successful in 5m22s
CI/CD Pipeline / e2e-tests (push) Has been skipped
CI/CD Pipeline / build (push) Has been skipped
26 lines
879 B
TypeScript
26 lines
879 B
TypeScript
import ReactExports from 'react';
|
|
import type { ReactNode } from 'react';
|
|
import type { StoreApi } from 'zustand';
|
|
type UseContextStore<S extends StoreApi<unknown>> = {
|
|
(): ExtractState<S>;
|
|
<U>(selector: (state: ExtractState<S>) => U, equalityFn?: (a: U, b: U) => boolean): U;
|
|
};
|
|
type ExtractState<S> = S extends {
|
|
getState: () => infer T;
|
|
} ? T : never;
|
|
type WithoutCallSignature<T> = {
|
|
[K in keyof T]: T[K];
|
|
};
|
|
/**
|
|
* @deprecated Use `createStore` and `useStore` for context usage
|
|
*/
|
|
declare function createContext<S extends StoreApi<unknown>>(): {
|
|
Provider: ({ createStore, children, }: {
|
|
createStore: () => S;
|
|
children: ReactNode;
|
|
}) => ReactExports.FunctionComponentElement<ReactExports.ProviderProps<S | undefined>>;
|
|
useStore: UseContextStore<S>;
|
|
useStoreApi: () => WithoutCallSignature<S>;
|
|
};
|
|
export default createContext;
|