@thejohnfreeman/loadable
Version:
Like react-loadable, but better.
12 lines (11 loc) • 480 B
TypeScript
import * as React from 'react';
declare type LoadableOptions = {
delay?: number;
Placeholder?: React.ComponentType;
};
declare type Imported<P> = React.ReactNode | React.ComponentType<P> | {
default: Imported<P>;
};
export declare type Fetch<P> = (props: P) => Promise<Imported<P>>;
export declare const loadable: ({ delay, Placeholder, }?: LoadableOptions) => <P extends object>(fetchElement: (props: P) => Promise<Imported<P>>) => React.ComponentType<P>;
export {};