UNPKG

1.93 kBTypeScriptView Raw
1import { ReactNode, ComponentType } from 'react';
2import { ResolverOptions, DeferTiming } from '@shopify/async';
3import { AsyncComponentType } from './types';
4interface Options<Props extends object, PreloadOptions extends object = {}, PrefetchOptions extends object = {}, KeepFreshOptions extends object = {}> extends ResolverOptions<ComponentType<Props>> {
5 defer?: DeferTiming | ((props: Props) => boolean);
6 deferHydration?: DeferTiming | ((props: Props) => boolean);
7 displayName?: string;
8 renderLoading?(props: Props): ReactNode;
9 renderError?(error: Error): ReactNode;
10 /**
11 * Custom logic to use for the usePreload hook of the new, async
12 * component. Because this logic will be used as part of a generated
13 * custom hook, it must follow the rules of hooks.
14 */
15 usePreload?(props: PreloadOptions): () => void;
16 /**
17 * Custom logic to use for the usePrefetch hook of the new, async
18 * component. Because this logic will be used as part of a generated
19 * custom hook, it must follow the rules of hooks.
20 */
21 usePrefetch?(props: PrefetchOptions): () => void;
22 /**
23 * Custom logic to use for the useKeepFresh hook of the new, async
24 * component. Because this logic will be used as part of a generated
25 * custom hook, it must follow the rules of hooks.
26 */
27 useKeepFresh?(props: KeepFreshOptions): () => void;
28}
29export declare function createAsyncComponent<Props extends object, PreloadOptions extends object = {}, PrefetchOptions extends object = {}, KeepFreshOptions extends object = {}>({ id, load, defer, deferHydration, displayName, renderLoading, renderError, usePreload: useCustomPreload, usePrefetch: useCustomPrefetch, useKeepFresh: useCustomKeepFresh, }: Options<Props, PreloadOptions, PrefetchOptions, KeepFreshOptions>): AsyncComponentType<ComponentType<Props>, Props, PreloadOptions, PrefetchOptions, KeepFreshOptions>;
30export {};