MCPcopy Create free account
hub / github.com/msgbyte/tailchat / Loadable

Function Loadable

client/web/src/components/Loadable.tsx:58–82  ·  view source on GitHub ↗
(
  loadFn: (props: Props) => Promise<DefaultComponent<Props>>,
  options?: LoadableOptions<Props>
)

Source from the content-addressed store, hash-verified

56 * @param loader 需要懒加载的组件
57 */
58export function Loadable<Props>(
59 loadFn: (props: Props) => Promise<DefaultComponent<Props>>,
60 options?: LoadableOptions<Props>
61): LoadableComponent<Props> {
62 return loadable(
63 (props) => {
64 let p = loadFn(props);
65
66 if (isValidStr(options?.componentName)) {
67 // 增加promise加载用时统计
68 p = promiseUsage(p, String(options?.componentName));
69 }
70
71 if (options?.showLoading === true) {
72 p = promiseLoading(p);
73 }
74
75 return pMinDelay(p, 200, { delayRejection: false });
76 },
77 {
78 fallback: <LoadingSpinner />,
79 ...options,
80 }
81 );
82}

Callers 15

App.tsxFile · 0.90
index.tsxFile · 0.90
index.tsxFile · 0.90
index.tsxFile · 0.90
index.tsxFile · 0.90
index.tsxFile · 0.90
index.tsxFile · 0.90
index.tsxFile · 0.90
index.tsxFile · 0.50
index.tsxFile · 0.50
CodeTag.tsxFile · 0.50
index.tsFile · 0.50

Calls 3

promiseUsageFunction · 0.85
promiseLoadingFunction · 0.85
isValidStrFunction · 0.50

Tested by

no test coverage detected