Skip to content

Commit a27a0d7

Browse files
committed
Fix flushing suspense fallbacks at the end of Act when the scheduler is mocked
1 parent 722bc04 commit a27a0d7

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

packages/react-reconciler/src/ReactFiberWorkLoop.new.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3717,7 +3717,7 @@ function finishPendingInteractions(root, committedLanes) {
37173717
// access to the same internals that we do here. Some trade offs in the
37183718
// implementation no longer make sense.
37193719

3720-
let isFlushingAct = false;
3720+
let isFlushingAct = null;
37213721
let isInsideThisAct = false;
37223722

37233723
// TODO: Yes, this is confusing. See above comment. We'll refactor it.
@@ -3726,6 +3726,13 @@ function shouldForceFlushFallbacksInDEV() {
37263726
// Never force flush in production. This function should get stripped out.
37273727
return false;
37283728
}
3729+
3730+
// `isFlushingAct` is used by ReactTestRenderer version of `act`.
3731+
if (isFlushingAct != null) {
3732+
// Flush callbacks at the end.
3733+
return isFlushingAct;
3734+
}
3735+
37293736
// `IsThisRendererActing.current` is used by ReactTestUtils version of `act`.
37303737
if (IsThisRendererActing.current) {
37313738
// `isInsideAct` is only used by the reconciler implementation of `act`.

packages/react-reconciler/src/ReactFiberWorkLoop.old.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3573,7 +3573,7 @@ function finishPendingInteractions(root, committedLanes) {
35733573
// access to the same internals that we do here. Some trade offs in the
35743574
// implementation no longer make sense.
35753575

3576-
let isFlushingAct = false;
3576+
let isFlushingAct = null;
35773577
let isInsideThisAct = false;
35783578

35793579
// TODO: Yes, this is confusing. See above comment. We'll refactor it.
@@ -3582,6 +3582,13 @@ function shouldForceFlushFallbacksInDEV() {
35823582
// Never force flush in production. This function should get stripped out.
35833583
return false;
35843584
}
3585+
3586+
// `isFlushingAct` is used by ReactTestRenderer version of `act`.
3587+
if (isFlushingAct != null) {
3588+
// Flush callbacks at the end.
3589+
return isFlushingAct;
3590+
}
3591+
35853592
// `IsThisRendererActing.current` is used by ReactTestUtils version of `act`.
35863593
if (IsThisRendererActing.current) {
35873594
// `isInsideAct` is only used by the reconciler implementation of `act`.

0 commit comments

Comments
 (0)