-
Notifications
You must be signed in to change notification settings - Fork 62
/
index.d.ts
48 lines (42 loc) · 1.32 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import * as React from 'react';
/**
* The configuration for an asynchronous component.
*/
export interface Configuration<P> {
resolve: () => Promise<React.ComponentType<P> | {default: React.ComponentType<P>}>;
LoadingComponent?: (props: P) => JSX.Element;
ErrorComponent?: (props: P & { error: Error }) => JSX.Element;
name?: string;
autoResolveES2015Default?: boolean;
env?: 'node' | 'browser';
serverMode?: 'resolve' | 'defer' | 'boundary';
}
/**
* A wrapper to provide the asynchronous component resolving in a React tree.
*/
export class AsyncComponentProvider extends React.Component<ProviderProps> {}
/**
* The properties that the {@link AsyncComponentProvider} accepts.
*/
export interface ProviderProps {
children: JSX.Element[] | JSX.Element;
asyncContext?: Context;
rehydrateState?: object;
}
/**
* This interface defines the asynchronous context uses for the asynchronous resolving
* of components.
*/
export interface Context {
getState: () => object;
}
/**
* Convert the given component to a an asynchronous component.
*
* @param config The configuration to use for the asynchronous component.
*/
export function asyncComponent<P>(config: Configuration<P>): React.ComponentType<P>;
/**
* Create a context for the asynchronous component resolving module.
*/
export function createAsyncContext(): Context;