File tree Expand file tree Collapse file tree
packages/react-reconciler/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -294,22 +294,26 @@ export function suspendCommit(): void {
294294 throw SuspenseyCommitException ;
295295}
296296
297+ function initLazy < T > ( lazyType : LazyComponentType < T , any > ) : T {
298+ if ( __DEV__ ) {
299+ return callLazyInitInDEV ( lazyType ) ;
300+ }
301+ const payload = lazyType . _payload ;
302+ const init = lazyType . _init ;
303+ return init ( payload ) ;
304+ }
305+
297306export function resolveLazy < T > (lazyType: LazyComponentType< T , any > ): T {
298307 try {
299- if ( __DEV__ ) {
300- return callLazyInitInDEV ( lazyType ) ;
301- }
302- const payload = lazyType . _payload ;
303- const init = lazyType . _init ;
304- return init ( payload ) ;
308+ return initLazy ( lazyType ) ;
305309 } catch ( x ) {
306310 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 ;
311+ // This lazy suspended . Treat this as if we called use() to unwrap it,
312+ // so we attach the same thenable bookkeeping immediately.
313+ const thenableState = createThenableState ( ) ;
314+ trackUsedThenable ( thenableState , ( x : any ) , 0 ) ;
315+ // If the thenable resolved synchronously, try again.
316+ return initLazy ( lazyType ) ;
313317 }
314318 throw x ;
315319 }
You can’t perform that action at this time.
0 commit comments