UNPKG

@uni-store/react

Version:
73 lines (61 loc) 3.17 kB
import type { DependencyList } from 'react'; import type { ForwardRefExoticComponent } from 'react'; import type { ForwardRefRenderFunction } from 'react'; import type { FunctionComponent } from 'react'; import type { MemoExoticComponent } from 'react'; import type { PropsWithoutRef } from 'react'; import type { RefAttributes } from 'react'; import type { RefForwardingComponent } from 'react'; import type { UnwrapNestedRefs } from '@uni-store/core'; /** * Create a `useSetup` function that defines setup state * @param setup - function that defines the setup state */ export declare function defineSetup<SS extends object>(setup: () => SS): () => UnwrapNestedRefs<SS>; /** * Create a `useSetup` function that defines setup state * @param setup - function that defines the setup state * @param props - Props */ export declare function defineSetup<SS extends object, Props>(setup: (props: UnwrapNestedRefs<Props>) => SS): (props: Props) => UnwrapNestedRefs<SS>; /** * Reactive React function component * @param baseComponent - the original function component * @param options - ReactiveReactOptions */ export declare function reactiveReact<P extends object, TRef = {}>(baseComponent: RefForwardingComponent<TRef, P>, options: ReactiveReactOptions & { forwardRef: true; }): MemoExoticComponent<ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<TRef>>>; export declare function reactiveReact<P extends object, TRef = {}>(baseComponent: ForwardRefRenderFunction<TRef, P>, options: ReactiveReactOptions & { forwardRef: true; }): MemoExoticComponent<ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<TRef>>>; export declare function reactiveReact<P extends object>(baseComponent: FunctionComponent<P>, options?: ReactiveReactOptions): FunctionComponent<P>; export declare function reactiveReact<C extends FunctionComponent<any> | RefForwardingComponent<any> | ForwardRefRenderFunction<any>, Options extends ReactiveReactOptions>(baseComponent: C, options?: Options): Options extends { forwardRef: true; } ? C extends ForwardRefRenderFunction<infer TRef, infer P> ? C & MemoExoticComponent<ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<TRef>>> : never : C & { displayName: string; }; /** * ReactiveReactOptions */ export declare interface ReactiveReactOptions { forwardRef?: boolean; } /** * useSetup with deps * @deprecated Use `useSetup(setup: (props: Props) => SS, props: Props)` * @param setup - function that defines the setup state */ export declare function useSetup<SS extends object, Deps extends DependencyList>(setup: () => SS, deps: Deps): UnwrapNestedRefs<SS>; /** * useSetup * @param setup - function that defines the setup state */ export declare function useSetup<SS extends object>(setup: () => SS): UnwrapNestedRefs<SS>; /** * useSetup with props * @param setup - function that defines the setup state * @param props - Props */ export declare function useSetup<SS extends object, Props extends object>(setup: (props: UnwrapNestedRefs<Props>) => SS, props: Props): UnwrapNestedRefs<SS>; export { }