File tree 2 files changed +49
-0
lines changed
packages/react-reconciler/src
2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -199,9 +199,11 @@ function throwException(
199
199
// to render it.
200
200
let currentSource = sourceFiber . alternate ;
201
201
if ( currentSource ) {
202
+ sourceFiber . updateQueue = currentSource . updateQueue ;
202
203
sourceFiber . memoizedState = currentSource . memoizedState ;
203
204
sourceFiber . expirationTime = currentSource . expirationTime ;
204
205
} else {
206
+ sourceFiber . updateQueue = null ;
205
207
sourceFiber . memoizedState = null ;
206
208
}
207
209
}
Original file line number Diff line number Diff line change @@ -1448,6 +1448,53 @@ function loadModules({
1448
1448
'Caught an error: Error in host config.' ,
1449
1449
) ;
1450
1450
} ) ;
1451
+
1452
+ it ( 'does not drop mounted effects' , async ( ) => {
1453
+ let never = { then ( ) { } } ;
1454
+
1455
+ let setShouldSuspend ;
1456
+ function App ( ) {
1457
+ const [ shouldSuspend , _setShouldSuspend ] = React . useState ( 0 ) ;
1458
+ setShouldSuspend = _setShouldSuspend ;
1459
+ return (
1460
+ < Suspense fallback = "Loading..." >
1461
+ < Child shouldSuspend = { shouldSuspend } />
1462
+ </ Suspense >
1463
+ ) ;
1464
+ }
1465
+
1466
+ function Child ( { shouldSuspend} ) {
1467
+ if ( shouldSuspend === 1 ) {
1468
+ throw never ;
1469
+ }
1470
+
1471
+ React . useEffect ( ( ) => {
1472
+ Scheduler . unstable_yieldValue ( 'Mount' ) ;
1473
+ return ( ) => {
1474
+ Scheduler . unstable_yieldValue ( 'Unmount' ) ;
1475
+ } ;
1476
+ } , [ ] ) ;
1477
+
1478
+ return 'Child' ;
1479
+ }
1480
+
1481
+ const root = ReactNoop . createLegacyRoot ( null ) ;
1482
+ await ReactNoop . act ( async ( ) => {
1483
+ root . render ( < App /> ) ;
1484
+ } ) ;
1485
+ expect ( Scheduler ) . toHaveYielded ( [ 'Mount' ] ) ;
1486
+
1487
+ // Suspend the child. This puts it into an inconsistent state.
1488
+ await ReactNoop . act ( async ( ) => {
1489
+ setShouldSuspend ( true ) ;
1490
+ } ) ;
1491
+
1492
+ // Unmount everying
1493
+ await ReactNoop . act ( async ( ) => {
1494
+ root . render ( null ) ;
1495
+ } ) ;
1496
+ expect ( Scheduler ) . toHaveYielded ( [ 'Unmount' ] ) ;
1497
+ } ) ;
1451
1498
} ) ;
1452
1499
1453
1500
it ( 'does not call lifecycles of a suspended component' , async ( ) => {
You can’t perform that action at this time.
0 commit comments