MCPcopy
hub / github.com/facebook/react / resolveLazy

Function resolveLazy

packages/react-reconciler/src/ReactFiberThenable.js:297–316  ·  view source on GitHub ↗
(lazyType: LazyComponentType<T, any>)

Source from the content-addressed store, hash-verified

295}
296
297export function resolveLazy<T>(lazyType: LazyComponentType<T, any>): T {
298 try {
299 if (__DEV__) {
300 return callLazyInitInDEV(lazyType);
301 }
302 const payload = lazyType._payload;
303 const init = lazyType._init;
304 return init(payload);
305 } catch (x) {
306 if (x !== null && typeof x === 'object' && typeof x.then === 'function') {
307 // This lazy Suspended. Treat this as if we called use() to unwrap it.
308 suspendedThenable = x;
309 if (__DEV__) {
310 needsToResetSuspendedThenableDEV = true;
311 }
312 throw SuspenseException;
313 }
314 throw x;
315 }
316}
317
318// This is used to track the actual thenable that suspended so it can be
319// passed to the rest of the Suspense implementation — which, for historical

Callers 10

mountLazyComponentFunction · 0.90
updateElementFunction · 0.90
createChildFunction · 0.90
updateSlotFunction · 0.90
updateFromMapFunction · 0.90
warnOnInvalidKeyFunction · 0.90
reconcileSingleElementFunction · 0.90
reconcileChildFibersImplFunction · 0.90

Calls 1

initFunction · 0.50

Tested by

no test coverage detected