1 | import { ReactNode, ComponentType } from 'react';
|
2 | import { ResolverOptions, DeferTiming } from '@shopify/async';
|
3 | import { AsyncComponentType } from './types';
|
4 | interface 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 |
|
18 |
|
19 |
|
20 |
|
21 | usePrefetch?(props: PrefetchOptions): () => void;
|
22 | |
23 |
|
24 |
|
25 |
|
26 |
|
27 | useKeepFresh?(props: KeepFreshOptions): () => void;
|
28 | }
|
29 | export 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>;
|
30 | export {};
|