@@ -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,7 @@ 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
+ if ( ! checkScheduledUpdateOrContext ( current , renderLanes ) ) {
486
484
// This will be the props with resolved defaultProps,
487
485
// unlike current.memoizedProps which will be the unresolved ones.
488
486
const prevProps = currentChild . memoizedProps ;
@@ -507,7 +505,6 @@ function updateSimpleMemoComponent(
507
505
workInProgress : Fiber ,
508
506
Component : any ,
509
507
nextProps : any ,
510
- updateLanes : Lanes ,
511
508
renderLanes : Lanes ,
512
509
) : null | Fiber {
513
510
// TODO: current can be non-null here even if the component
@@ -553,7 +550,7 @@ function updateSimpleMemoComponent(
553
550
( __DEV__ ? workInProgress . type === current . type : true )
554
551
) {
555
552
didReceiveUpdate = false ;
556
- if ( ! includesSomeLane ( renderLanes , updateLanes ) ) {
553
+ if ( ! checkScheduledUpdateOrContext ( current , renderLanes ) ) {
557
554
// The pending lanes were cleared at the beginning of beginWork. We're
558
555
// about to bail out, but there might be other lanes that weren't
559
556
// included in the current render. Usually, the priority level of the
@@ -740,7 +737,6 @@ const updateLegacyHiddenComponent = updateOffscreenComponent;
740
737
function updateCacheComponent (
741
738
current : Fiber | null ,
742
739
workInProgress : Fiber ,
743
- updateLanes : Lanes ,
744
740
renderLanes : Lanes ,
745
741
) {
746
742
if ( ! enableCache ) {
@@ -762,7 +758,7 @@ function updateCacheComponent(
762
758
pushCacheProvider ( workInProgress , freshCache ) ;
763
759
} else {
764
760
// Check for updates
765
- if ( includesSomeLane ( renderLanes , updateLanes ) ) {
761
+ if ( includesSomeLane ( current . lanes , renderLanes ) ) {
766
762
cloneUpdateQueue ( current , workInProgress ) ;
767
763
processUpdateQueue ( workInProgress , null , null , renderLanes ) ;
768
764
}
@@ -1306,7 +1302,6 @@ function mountLazyComponent(
1306
1302
_current ,
1307
1303
workInProgress ,
1308
1304
elementType ,
1309
- updateLanes ,
1310
1305
renderLanes ,
1311
1306
) {
1312
1307
if ( _current !== null ) {
@@ -1396,7 +1391,6 @@ function mountLazyComponent(
1396
1391
workInProgress ,
1397
1392
Component ,
1398
1393
resolveDefaultProps ( Component . type , resolvedProps ) , // The inner type can have defaults too
1399
- updateLanes ,
1400
1394
renderLanes ,
1401
1395
) ;
1402
1396
return child ;
@@ -3222,6 +3216,27 @@ function remountFiber(
3222
3216
}
3223
3217
}
3224
3218
3219
+ function checkScheduledUpdateOrContext (
3220
+ current : Fiber ,
3221
+ renderLanes : Lanes ,
3222
+ ) : boolean {
3223
+ // Before performing an early bailout, we must check if there are pending
3224
+ // updates or context.
3225
+ const updateLanes = current . lanes ;
3226
+ if ( includesSomeLane ( renderLanes , updateLanes ) ) {
3227
+ return true ;
3228
+ }
3229
+ // No pending update, but because context is propagated lazily, we need
3230
+ // to check for a context change before we bail out.
3231
+ if ( enableLazyContextPropagation ) {
3232
+ const dependencies = current . dependencies ;
3233
+ if ( dependencies !== null && checkIfContextChanged ( dependencies ) ) {
3234
+ return true ;
3235
+ }
3236
+ }
3237
+ return false ;
3238
+ }
3239
+
3225
3240
function attemptEarlyBailoutIfNoScheduledUpdate (
3226
3241
current : Fiber ,
3227
3242
workInProgress : Fiber ,
@@ -3436,8 +3451,6 @@ function beginWork(
3436
3451
workInProgress : Fiber ,
3437
3452
renderLanes : Lanes ,
3438
3453
) : Fiber | null {
3439
- let updateLanes = workInProgress . lanes ;
3440
-
3441
3454
if ( __DEV__ ) {
3442
3455
if ( workInProgress . _debugNeedsRemount && current !== null ) {
3443
3456
// This will restart the begin phase with a new fiber.
@@ -3457,17 +3470,6 @@ function beginWork(
3457
3470
}
3458
3471
3459
3472
if ( current !== null ) {
3460
- // TODO: The factoring of this block is weird.
3461
- if (
3462
- enableLazyContextPropagation &&
3463
- ! includesSomeLane ( renderLanes , updateLanes )
3464
- ) {
3465
- const dependencies = current . dependencies ;
3466
- if ( dependencies !== null && checkIfContextChanged ( dependencies ) ) {
3467
- updateLanes = mergeLanes ( updateLanes , renderLanes ) ;
3468
- }
3469
- }
3470
-
3471
3473
const oldProps = current . memoizedProps ;
3472
3474
const newProps = workInProgress . pendingProps ;
3473
3475
@@ -3480,14 +3482,23 @@ function beginWork(
3480
3482
// If props or context changed, mark the fiber as having performed work.
3481
3483
// This may be unset if the props are determined to be equal later (memo).
3482
3484
didReceiveUpdate = true ;
3483
- } else if ( ! includesSomeLane ( renderLanes , updateLanes ) ) {
3484
- didReceiveUpdate = false ;
3485
- return attemptEarlyBailoutIfNoScheduledUpdate (
3486
- current ,
3487
- workInProgress ,
3488
- renderLanes ,
3489
- ) ;
3490
3485
} else {
3486
+ // Neither props nor legacy context changes. Check if there's a pending
3487
+ // update or context change.
3488
+ if (
3489
+ ! checkScheduledUpdateOrContext ( current , renderLanes ) &&
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
+ }
3491
3502
if ( ( current . flags & ForceUpdateForLegacySuspense ) !== NoFlags ) {
3492
3503
// This is a special case that only exists for legacy mode.
3493
3504
// See https://github.com/facebook/react/pull/19216.
@@ -3526,7 +3537,6 @@ function beginWork(
3526
3537
current ,
3527
3538
workInProgress ,
3528
3539
elementType ,
3529
- updateLanes ,
3530
3540
renderLanes ,
3531
3541
) ;
3532
3542
}
@@ -3619,7 +3629,6 @@ function beginWork(
3619
3629
workInProgress ,
3620
3630
type ,
3621
3631
resolvedProps ,
3622
- updateLanes ,
3623
3632
renderLanes ,
3624
3633
) ;
3625
3634
}
@@ -3629,7 +3638,6 @@ function beginWork(
3629
3638
workInProgress ,
3630
3639
workInProgress . type ,
3631
3640
workInProgress . pendingProps ,
3632
- updateLanes ,
3633
3641
renderLanes ,
3634
3642
) ;
3635
3643
}
@@ -3665,12 +3673,7 @@ function beginWork(
3665
3673
}
3666
3674
case CacheComponent : {
3667
3675
if ( enableCache ) {
3668
- return updateCacheComponent (
3669
- current ,
3670
- workInProgress ,
3671
- updateLanes ,
3672
- renderLanes ,
3673
- ) ;
3676
+ return updateCacheComponent ( current , workInProgress , renderLanes ) ;
3674
3677
}
3675
3678
break ;
3676
3679
}
0 commit comments