# Function lazy

- lazy<T>(load): LazyExoticComponent<T>

- Lets you defer loading a component’s code until it is rendered for the first time.

  #### Type Parameters

  - T extends ComponentType<any>

  #### Parameters

  - load: (() => Promise<{
    default: T;
    }>)

    A function that returns a `Promise` or another thenable (a `Promise`-like object with a then method). React will not call `load` until the first time you attempt to render the returned component. After React first calls load, it will wait for it to resolve, and then render the resolved value’s `.default` as a React component. Both the returned `Promise` and the `Promise`’s resolved value will be cached, so React will not call load more than once. If the `Promise` rejects, React will throw the rejection reason for the nearest Error Boundary to handle.

    - - (): Promise<{
        default: T;
        }>

      - #### Returns Promise<{
        default: T;
        }>

  #### Returns LazyExoticComponent<T>

  #### See

  React Docs

  #### Example

      import { lazy } from 'react';

      const MarkdownPreview = lazy(() => import('./MarkdownPreview.js'));

  - Defined in common/temp/node_modules/.pnpm/@types+react@18.3.3/node_modules/@types/react/index.d.ts:1795