Component APIs

lazy

Edit this page
function lazy<T extends Component<any>>(
fn: () => Promise<{ default: T }>
): T & { preload: () => Promise<T> }

Used to lazy load components to allow for code splitting. Components are not loaded until rendered. Lazy loaded components can be used the same as its statically imported counterpart, receiving props etc. Lazy components trigger <Suspense>

// wrap import
const ComponentA = lazy(() => import("./ComponentA"));
// use in JSX
<ComponentA title={props.title} />
Report an issue with this page