@@ -1110,16 +1110,8 @@ function updateClassComponent(
1110
1110
const instance = workInProgress . stateNode ;
1111
1111
let shouldUpdate ;
1112
1112
if ( instance === null ) {
1113
- if ( current !== null ) {
1114
- // A class component without an instance only mounts if it suspended
1115
- // inside a non-concurrent tree, in an inconsistent state. We want to
1116
- // treat it like a new mount, even though an empty version of it already
1117
- // committed. Disconnect the alternate pointers.
1118
- current . alternate = null ;
1119
- workInProgress . alternate = null ;
1120
- // Since this is conceptually a new fiber, schedule a Placement effect
1121
- workInProgress . flags |= Placement ;
1122
- }
1113
+ resetSuspendedCurrentOnMountInLegacyMode ( current , workInProgress ) ;
1114
+
1123
1115
// In the initial pass we might need to construct the instance.
1124
1116
constructClassInstance ( workInProgress , Component , nextProps ) ;
1125
1117
mountClassInstance ( workInProgress , Component , nextProps , renderLanes ) ;
@@ -1469,16 +1461,7 @@ function mountLazyComponent(
1469
1461
elementType ,
1470
1462
renderLanes ,
1471
1463
) {
1472
- if ( _current !== null ) {
1473
- // A lazy component only mounts if it suspended inside a non-
1474
- // concurrent tree, in an inconsistent state. We want to treat it like
1475
- // a new mount, even though an empty version of it already committed.
1476
- // Disconnect the alternate pointers.
1477
- _current . alternate = null ;
1478
- workInProgress . alternate = null ;
1479
- // Since this is conceptually a new fiber, schedule a Placement effect
1480
- workInProgress . flags |= Placement ;
1481
- }
1464
+ resetSuspendedCurrentOnMountInLegacyMode ( _current , workInProgress ) ;
1482
1465
1483
1466
const props = workInProgress . pendingProps ;
1484
1467
const lazyComponent : LazyComponentType < any , any > = elementType ;
@@ -1588,16 +1571,7 @@ function mountIncompleteClassComponent(
1588
1571
nextProps ,
1589
1572
renderLanes ,
1590
1573
) {
1591
- if ( _current !== null ) {
1592
- // An incomplete component only mounts if it suspended inside a non-
1593
- // concurrent tree, in an inconsistent state. We want to treat it like
1594
- // a new mount, even though an empty version of it already committed.
1595
- // Disconnect the alternate pointers.
1596
- _current . alternate = null ;
1597
- workInProgress . alternate = null ;
1598
- // Since this is conceptually a new fiber, schedule a Placement effect
1599
- workInProgress . flags |= Placement ;
1600
- }
1574
+ resetSuspendedCurrentOnMountInLegacyMode ( _current , workInProgress ) ;
1601
1575
1602
1576
// Promote the fiber to a class and try rendering again.
1603
1577
workInProgress . tag = ClassComponent ;
@@ -1635,16 +1609,7 @@ function mountIndeterminateComponent(
1635
1609
Component ,
1636
1610
renderLanes ,
1637
1611
) {
1638
- if ( _current !== null ) {
1639
- // An indeterminate component only mounts if it suspended inside a non-
1640
- // concurrent tree, in an inconsistent state. We want to treat it like
1641
- // a new mount, even though an empty version of it already committed.
1642
- // Disconnect the alternate pointers.
1643
- _current . alternate = null ;
1644
- workInProgress . alternate = null ;
1645
- // Since this is conceptually a new fiber, schedule a Placement effect
1646
- workInProgress . flags |= Placement ;
1647
- }
1612
+ resetSuspendedCurrentOnMountInLegacyMode ( _current , workInProgress ) ;
1648
1613
1649
1614
const props = workInProgress . pendingProps ;
1650
1615
let context ;
@@ -3376,6 +3341,21 @@ export function checkIfWorkInProgressReceivedUpdate() {
3376
3341
return didReceiveUpdate ;
3377
3342
}
3378
3343
3344
+ function resetSuspendedCurrentOnMountInLegacyMode ( current , workInProgress ) {
3345
+ if ( ( workInProgress . mode & ConcurrentMode ) === NoMode ) {
3346
+ if ( current !== null ) {
3347
+ // A lazy component only mounts if it suspended inside a non-
3348
+ // concurrent tree, in an inconsistent state. We want to treat it like
3349
+ // a new mount, even though an empty version of it already committed.
3350
+ // Disconnect the alternate pointers.
3351
+ current . alternate = null ;
3352
+ workInProgress . alternate = null ;
3353
+ // Since this is conceptually a new fiber, schedule a Placement effect
3354
+ workInProgress . flags |= Placement ;
3355
+ }
3356
+ }
3357
+ }
3358
+
3379
3359
function bailoutOnAlreadyFinishedWork (
3380
3360
current : Fiber | null ,
3381
3361
workInProgress : Fiber ,
0 commit comments