UNPKG

972 BTypeScriptView Raw
1import * as React from 'react';
2import { ComponentOptions, DefaultComponentImport, HOCOptions, HOCType, LazyImport } from '../types';
3/**
4 * creates a "lazy" component, like `React.lazy`
5 * @see {@link useImported} or {@link useLazy}
6 * @param {Function} loaderFunction - () => import('a'), or () => require('b')
7 * @param {Object} [options]
8 * @param {React.Component} [options.LoadingComponent]
9 * @param {React.Component} [options.ErrorComponent]
10 * @param {Function} [options.onError] - error handler. Will consume the real error.
11 * @param {Function} [options.async = false] - enable React 16+ suspense.
12 *
13 * @example
14 * const PageA = imported('./pageA', { async: true });
15 */
16declare function loader<P, K = P>(loaderFunction: DefaultComponentImport<P>, baseOptions?: Partial<ComponentOptions<P, K>> & HOCOptions): HOCType<P, K>;
17/**
18 * React.lazy "as-is" replacement
19 */
20export declare function lazy<T>(importer: LazyImport<T>): React.FC<T>;
21export default loader;