@mui/internal-docs-infra
Version:
MUI Infra - internal documentation creation tools.
18 lines (15 loc) • 766 B
JavaScript
'use client';
import * as React from 'react';
/**
* Memoize a preload by key: the first call with a given `key` runs `factory`
* and caches its promise; later calls with the same key return that promise. So
* many instances that need the same helper share one dynamic `import()` (and
* one round of any work the factory does) instead of each kicking off their own.
*/
/**
* Provides the cross-instance `PreloadFn`. `undefined` outside a
* `PreloadProvider` - `usePreload` then falls back to calling the factory
* directly (the browser's module cache still dedups identical `import()`s).
*/
export const PreloadContext = /*#__PURE__*/React.createContext(undefined);
if (process.env.NODE_ENV !== "production") PreloadContext.displayName = "PreloadContext";