React.lazy

The React function that defines a component whose code is loaded with a dynamic import the first time it renders.

In more detail

lazy(() => import("./Settings")) returns a component that suspends while its code downloads, so it must be rendered inside a Suspense boundary. Declare lazy components at the top level of a module, never inside another component, or their state resets every render.

Example

const SettingsModal = lazy(() => import("./SettingsModal"));

Related terms

Taught in

References