[]previous and next page

LazyComponent

A component made by lazy: call it (or write it in JSX) like any component, and use preload to start the load early.

A component made by lazy: call it (or write it in JSX) like any component, and use preload to start the load early.

Import#

ts
import type { LazyComponent } from "@shadow-js/web";

Signature#

ts
interface LazyComponent<P> {
  /**
   * Renders the loaded component with `props`. While the code is loading the result is empty and the
   * nearest `<Suspense>` shows its fallback; without a boundary nothing is rendered until the load
   * resolves.
   */
  (props: P): Accessor<unknown>;
  /**
   * Starts loading without rendering and resolves to the component. Calls share one load, so the
   * loader runs once. A failed load is not cached: the next call or render loads again.
   */
  preload(): Promise<ComponentFunction<P>>;
}

Members#

Name Type Description
P P
preload preload(): Promise<ComponentFunction<P>> Starts loading without rendering and resolves to the component. Calls share one load, so the loader runs once. A failed load is not cached: the next call or render loads again.