forked from theKashey/react-imported-component
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodule.js.flow
More file actions
62 lines (41 loc) · 2.1 KB
/
module.js.flow
File metadata and controls
62 lines (41 loc) · 2.1 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
// @flow
import * as React from 'react'
interface DefaultImportedComponent<P> {
default: React.ComponentType<P>
}
type DefaultComponent<P> = React.ComponentType<P> | DefaultImportedComponent<P>;
type LoadableComponentState = 'loading' | 'done' | 'error';
type ComponentRenderOption<P, K> = (Component: K, State: LoadableComponentState, props: P) => React.ElementType;
type ComponentOptions<P, K> = {
LoadingComponent?: React.ComponentType<any>,
ErrorComponent?: React.ComponentType<any>,
exportPicker?: (a: any) => any,
onError?: (a: any) => any,
render?:ComponentRenderOption<P,K>,
async?: boolean,
forwardProps?: P,
forwardRef?: React.Ref<P>
};
interface ImportedComponents {
[index: number]: () => Promise<DefaultComponent<any>>
}
type LoadableResource<P> = {};
type IComponentLoaderProps<P> = ComponentOptions<P> & {
loadable: LoadableResource<P> | Promise<DefaultComponent<P>>
};
declare interface importedComponent {
<P, K>(loader: () => Promise<DefaultComponent<P>>, options?: $Exact<ComponentOptions<P, K, React.ComponentType<P>>>): React.ComponentType<P | K>;
<P, K>(loader: () => Promise<P>, options?: $Exact<ComponentOptions<P, K, P>> & { render: ComponentRenderOption<P, K> }): React.ComponentType<K>;
}
declare export class ComponentLoader<T> extends React.Component<$Exact<IComponentLoaderProps<T>>> {
}
declare export function ImportedStream({ takeUID: (streamId: number) => any }): null;
declare export function printDrainHydrateMarks(streamId?: number): string
declare export function drainHydrateMarks(streamId?: number): Array<string>
declare export function rehydrateMarks(marks?: Array<string>): Promise<void>
declare export function whenComponentsReady(): Promise<void>
declare export function dryRender(renderFunction: () => any): Promise<void>
declare export function assignImportedComponents(importedComponents: ImportedComponents): void
declare export function loadableResource<P>(loader: () => Promise<DefaultComponent<P>>): LoadableResource<P>
declare export function setConfiguration(config: { SSR?: boolean, hot?: boolean }): void;
declare export default importedComponent;