@zero-library/common 2.3.4 → 2.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1383,14 +1383,17 @@ var styles_module_default2 = {
1383
1383
  var baseComponentMap = {
1384
1384
  // renderMarkdown: () => import('@/components/RenderMarkdown')
1385
1385
  };
1386
+ var lazyCache = /* @__PURE__ */ new Map();
1386
1387
  var LazyComponent_default = ({ type, customComponents, unknownContent, ...rest }) => {
1387
- const componentMap = React.useMemo(() => {
1388
- return { ...baseComponentMap, ...customComponents };
1389
- }, [customComponents]);
1388
+ const loader = customComponents?.[type] || baseComponentMap[type];
1390
1389
  const LazyComponent = React.useMemo(() => {
1391
- const loader = componentMap[type];
1392
- return loader ? React.lazy(loader) : null;
1393
- }, [type, componentMap]);
1390
+ if (!loader) return null;
1391
+ const cached = lazyCache.get(type);
1392
+ if (cached) return cached;
1393
+ const component = React.lazy(loader);
1394
+ lazyCache.set(type, component);
1395
+ return component;
1396
+ }, [loader]);
1394
1397
  if (!LazyComponent) return unknownContent || /* @__PURE__ */ jsxRuntime.jsx(antd.Alert, { message: `\u672A\u77E5\u7C7B\u578B\uFF1A${type}`, type: "warning" });
1395
1398
  return /* @__PURE__ */ jsxRuntime.jsx(
1396
1399
  React.Suspense,