UNPKG

1.41 kBTypeScriptView Raw
1/// <reference types="react" />
2import * as React from 'react';
3export interface AsyncRouteComponentProps {
4 isInitialRender: boolean;
5 setAppState: (data: any) => void;
6}
7export interface AsyncRouteComponentState {
8 Component: React.ReactNode | null;
9}
10/**
11 * Returns a new React component, ready to be instantiated.
12 * Note the closure here protecting Component, and providing a unique
13 * instance of Component to the static implementation of `load`.
14 */
15export declare function asyncComponent<Props = any>({loader, Placeholder}: {
16 loader: () => Promise<any>;
17 Placeholder?: React.ComponentType<Props>;
18}): {
19 new (props: any): {
20 componentWillMount(): void;
21 updateState(): void;
22 render(): JSX.Element | null;
23 setState<K extends "Component">(state: AsyncRouteComponentState | ((prevState: Readonly<AsyncRouteComponentState>, props: any) => AsyncRouteComponentState | Pick<AsyncRouteComponentState, K>) | Pick<AsyncRouteComponentState, K>, callback?: (() => void) | undefined): void;
24 forceUpdate(callBack?: (() => void) | undefined): void;
25 props: Readonly<{
26 children?: React.ReactNode;
27 }> & Readonly<any>;
28 state: Readonly<AsyncRouteComponentState>;
29 context: any;
30 refs: {
31 [key: string]: React.ReactInstance;
32 };
33 };
34 load(): Promise<void>;
35 getInitialProps(ctx: any): any;
36};
37
\No newline at end of file