@@ -409,7 +409,6 @@ function updateMemoComponent(
409
409
workInProgress : Fiber ,
410
410
Component : any ,
411
411
nextProps : any ,
412
- updateLanes : Lanes ,
413
412
renderLanes : Lanes ,
414
413
) : null | Fiber {
415
414
if ( current === null ) {
@@ -437,7 +436,6 @@ function updateMemoComponent(
437
436
workInProgress ,
438
437
resolvedType ,
439
438
nextProps ,
440
- updateLanes ,
441
439
renderLanes ,
442
440
) ;
443
441
}
@@ -482,7 +480,11 @@ function updateMemoComponent(
482
480
}
483
481
}
484
482
const currentChild = ( ( current . child : any ) : Fiber ) ; // This is always exactly one child
485
- if ( ! includesSomeLane ( updateLanes , renderLanes ) ) {
483
+ const hasScheduledUpdateOrContext = checkScheduledUpdateOrContext (
484
+ current ,
485
+ renderLanes ,
486
+ ) ;
487
+ if ( ! hasScheduledUpdateOrContext ) {
486
488
// This will be the props with resolved defaultProps,
487
489
// unlike current.memoizedProps which will be the unresolved ones.
488
490
const prevProps = currentChild . memoizedProps ;
@@ -507,7 +509,6 @@ function updateSimpleMemoComponent(
507
509
workInProgress : Fiber ,
508
510
Component : any ,
509
511
nextProps : any ,
510
- updateLanes : Lanes ,
511
512
renderLanes : Lanes ,
512
513
) : null | Fiber {
513
514
// TODO: current can be non-null here even if the component
@@ -553,7 +554,7 @@ function updateSimpleMemoComponent(
553
554
( __DEV__ ? workInProgress . type === current . type : true )
554
555
) {
555
556
didReceiveUpdate = false ;
556
- if ( ! includesSomeLane ( renderLanes , updateLanes ) ) {
557
+ if ( ! checkScheduledUpdateOrContext ( current , renderLanes ) ) {
557
558
// The pending lanes were cleared at the beginning of beginWork. We're
558
559
// about to bail out, but there might be other lanes that weren't
559
560
// included in the current render. Usually, the priority level of the
@@ -740,7 +741,6 @@ const updateLegacyHiddenComponent = updateOffscreenComponent;
740
741
function updateCacheComponent (
741
742
current : Fiber | null ,
742
743
workInProgress : Fiber ,
743
- updateLanes : Lanes ,
744
744
renderLanes : Lanes ,
745
745
) {
746
746
if ( ! enableCache ) {
@@ -762,7 +762,7 @@ function updateCacheComponent(
762
762
pushCacheProvider ( workInProgress , freshCache ) ;
763
763
} else {
764
764
// Check for updates
765
- if ( includesSomeLane ( renderLanes , updateLanes ) ) {
765
+ if ( includesSomeLane ( current . lanes , renderLanes ) ) {
766
766
cloneUpdateQueue ( current , workInProgress ) ;
767
767
processUpdateQueue ( workInProgress , null , null , renderLanes ) ;
768
768
}
@@ -1306,7 +1306,6 @@ function mountLazyComponent(
1306
1306
_current ,
1307
1307
workInProgress ,
1308
1308
elementType ,
1309
- updateLanes ,
1310
1309
renderLanes ,
1311
1310
) {
1312
1311
if ( _current !== null ) {
@@ -1396,7 +1395,6 @@ function mountLazyComponent(
1396
1395
workInProgress ,
1397
1396
Component ,
1398
1397
resolveDefaultProps ( Component . type , resolvedProps ) , // The inner type can have defaults too
1399
- updateLanes ,
1400
1398
renderLanes ,
1401
1399
) ;
1402
1400
return child ;
@@ -3214,6 +3212,27 @@ function remountFiber(
3214
3212
}
3215
3213
}
3216
3214
3215
+ function checkScheduledUpdateOrContext (
3216
+ current : Fiber ,
3217
+ renderLanes : Lanes ,
3218
+ ) : boolean {
3219
+ // Before performing an early bailout, we must check if there are pending
3220
+ // updates or context.
3221
+ const updateLanes = current . lanes ;
3222
+ if ( includesSomeLane ( updateLanes , renderLanes ) ) {
3223
+ return true ;
3224
+ }
3225
+ // No pending update, but because context is propagated lazily, we need
3226
+ // to check for a context change before we bail out.
3227
+ if ( enableLazyContextPropagation ) {
3228
+ const dependencies = current . dependencies ;
3229
+ if ( dependencies !== null && checkIfContextChanged ( dependencies ) ) {
3230
+ return true ;
3231
+ }
3232
+ }
3233
+ return false ;
3234
+ }
3235
+
3217
3236
function attemptEarlyBailoutIfNoScheduledUpdate (
3218
3237
current : Fiber ,
3219
3238
workInProgress : Fiber ,
@@ -3428,8 +3447,6 @@ function beginWork(
3428
3447
workInProgress : Fiber ,
3429
3448
renderLanes : Lanes ,
3430
3449
) : Fiber | null {
3431
- let updateLanes = workInProgress . lanes ;
3432
-
3433
3450
if ( __DEV__ ) {
3434
3451
if ( workInProgress . _debugNeedsRemount && current !== null ) {
3435
3452
// This will restart the begin phase with a new fiber.
@@ -3449,17 +3466,6 @@ function beginWork(
3449
3466
}
3450
3467
3451
3468
if ( current !== null ) {
3452
- // TODO: The factoring of this block is weird.
3453
- if (
3454
- enableLazyContextPropagation &&
3455
- ! includesSomeLane ( renderLanes , updateLanes )
3456
- ) {
3457
- const dependencies = current . dependencies ;
3458
- if ( dependencies !== null && checkIfContextChanged ( dependencies ) ) {
3459
- updateLanes = mergeLanes ( updateLanes , renderLanes ) ;
3460
- }
3461
- }
3462
-
3463
3469
const oldProps = current . memoizedProps ;
3464
3470
const newProps = workInProgress . pendingProps ;
3465
3471
@@ -3472,14 +3478,27 @@ function beginWork(
3472
3478
// If props or context changed, mark the fiber as having performed work.
3473
3479
// This may be unset if the props are determined to be equal later (memo).
3474
3480
didReceiveUpdate = true ;
3475
- } else if ( ! includesSomeLane ( renderLanes , updateLanes ) ) {
3476
- didReceiveUpdate = false ;
3477
- return attemptEarlyBailoutIfNoScheduledUpdate (
3481
+ } else {
3482
+ // Neither props nor legacy context changes. Check if there's a pending
3483
+ // update or context change.
3484
+ const hasScheduledUpdateOrContext = checkScheduledUpdateOrContext (
3478
3485
current ,
3479
- workInProgress ,
3480
3486
renderLanes ,
3481
3487
) ;
3482
- } else {
3488
+ if (
3489
+ ! hasScheduledUpdateOrContext &&
3490
+ // If this is the second pass of an error or suspense boundary, there
3491
+ // may not be work scheduled on `current`, so we check for this flag.
3492
+ ( workInProgress . flags & DidCapture ) === NoFlags
3493
+ ) {
3494
+ // No pending updates or context. Bail out now.
3495
+ didReceiveUpdate = false ;
3496
+ return attemptEarlyBailoutIfNoScheduledUpdate (
3497
+ current ,
3498
+ workInProgress ,
3499
+ renderLanes ,
3500
+ ) ;
3501
+ }
3483
3502
if ( ( current . flags & ForceUpdateForLegacySuspense ) !== NoFlags ) {
3484
3503
// This is a special case that only exists for legacy mode.
3485
3504
// See https://github.com/facebook/react/pull/19216.
@@ -3518,7 +3537,6 @@ function beginWork(
3518
3537
current ,
3519
3538
workInProgress ,
3520
3539
elementType ,
3521
- updateLanes ,
3522
3540
renderLanes ,
3523
3541
) ;
3524
3542
}
@@ -3611,7 +3629,6 @@ function beginWork(
3611
3629
workInProgress ,
3612
3630
type ,
3613
3631
resolvedProps ,
3614
- updateLanes ,
3615
3632
renderLanes ,
3616
3633
) ;
3617
3634
}
@@ -3621,7 +3638,6 @@ function beginWork(
3621
3638
workInProgress ,
3622
3639
workInProgress . type ,
3623
3640
workInProgress . pendingProps ,
3624
- updateLanes ,
3625
3641
renderLanes ,
3626
3642
) ;
3627
3643
}
@@ -3657,12 +3673,7 @@ function beginWork(
3657
3673
}
3658
3674
case CacheComponent : {
3659
3675
if ( enableCache ) {
3660
- return updateCacheComponent (
3661
- current ,
3662
- workInProgress ,
3663
- updateLanes ,
3664
- renderLanes ,
3665
- ) ;
3676
+ return updateCacheComponent ( current , workInProgress , renderLanes ) ;
3666
3677
}
3667
3678
break ;
3668
3679
}
0 commit comments