File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ import * as React from 'react' ;
2+
3+ /**
4+ * The configuration for an asynchronous component.
5+ */
6+ export interface Configuration < P > {
7+ resolve : ( ) => Promise < React . Component < P > > ;
8+ LoadingComponent ?: ( props : P ) => JSX . Element ;
9+ ErrorComponent ?: ( props : P & { error : Error } ) => JSX . Element ;
10+ name ?: string ;
11+ autoResolveES2015Default ?: boolean ;
12+ env ?: 'node' | 'browser' ;
13+ serverMode ?: 'resolve' | 'defer' | 'boundary' ;
14+ }
15+
16+ /**
17+ * A wrapper to provide the asynchronous component resolving in a React tree.
18+ */
19+ export class AsyncComponentProvider extends React . Component < ProviderProps > { }
20+
21+ /**
22+ * The properties that the {@link AsyncComponentProvider} accepts.
23+ */
24+ export interface ProviderProps {
25+ children : JSX . Element [ ] | JSX . Element ;
26+ asyncContext ?: Context ;
27+ rehydrateState ?: object ;
28+ }
29+
30+ /**
31+ * This interface defines the asynchronous context uses for the asynchronous resolving
32+ * of components.
33+ */
34+ export interface Context {
35+ getState : ( ) => object ;
36+ }
37+
38+ /**
39+ * Convert the given component to a an asynchronous component.
40+ *
41+ * @param config The configuration to use for the asynchronous component.
42+ */
43+ export function asyncComponent < T extends React . Component < P > , P > ( config : Configuration < P > ) : React . ComponentClass < P > ;
44+
45+ /**
46+ * Create a context for the asynchronous component resolving module.
47+ */
48+ export function createAsyncContext ( ) : Context ;
Original file line number Diff line number Diff line change 1010 " umd" ,
1111 " commonjs"
1212 ],
13+ "typings" : " ./index.d.ts" ,
1314 "repository" : {
1415 "type" : " git" ,
1516 "url" : " https://github.com/ctrlplusb/react-async-component.git"
You can’t perform that action at this time.
0 commit comments