@mui/internal-docs-infra
Version:
MUI Infra - internal documentation creation tools.
26 lines • 1.32 kB
text/typescript
import * as React from 'react';
import type { LazyContentProps } from "./types.mjs";
/**
* Lazily import a component and render it once its chunk has loaded, reporting
* readiness to the settle gate - so the page can coordinate the swap and a
* `StreamController` can reflect it in `loading`.
*
* The import runs in an effect (not `React.lazy` + Suspense) on purpose: the swap
* that reveals this content mounts/unmounts the subtree around a pending `import()`,
* and a Suspense boundary that comes and goes around a pending promise trips React's
* async-info-on-boundary tracking ("cleaning up async info that was not on the
* parent Suspense boundary"). Loading in an effect avoids a Suspense boundary
* entirely, and renders only the fallback during SSR (effects don't run there).
*
* The import factory is captured once (via lazy `useState`), so an inline
* `content={() => import('./X')}` doesn't restart the import every render. While
* the module loads, the explicit `fallback` (or, if none, the coordinating swap's
* fallback from {@link CoordinatedContentContext}) is shown - so the same
* placeholder keeps covering the load, with no empty flash.
*/
export declare function LazyContent<T extends {} = {}>({
content,
props,
fallback,
gate
}: LazyContentProps<T>): React.ReactElement;