Skip to content

Commit 0e37320

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

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3737,7 +3737,6 @@ function shouldForceFlushFallbacksInDEV() {
37373737
}
37383738

37393739
const flushMockScheduler = Scheduler.unstable_flushAllWithoutAsserting;
3740-
const isSchedulerMocked = typeof flushMockScheduler === 'function';
37413740

37423741
// Returns whether additional work was scheduled. Caller should keep flushing
37433742
// until there's no work left.
@@ -3867,11 +3866,7 @@ export function act(callback: () => Thenable<mixed>): Thenable<void> {
38673866
called = true;
38683867
result.then(
38693868
() => {
3870-
if (
3871-
actingUpdatesScopeDepth > 1 ||
3872-
(isSchedulerMocked === true &&
3873-
previousIsSomeRendererActing === true)
3874-
) {
3869+
if (actingUpdatesScopeDepth > 1) {
38753870
onDone();
38763871
resolve();
38773872
return;
@@ -3907,10 +3902,7 @@ export function act(callback: () => Thenable<mixed>): Thenable<void> {
39073902

39083903
// flush effects until none remain, and cleanup
39093904
try {
3910-
if (
3911-
actingUpdatesScopeDepth === 1 &&
3912-
(isSchedulerMocked === false || previousIsSomeRendererActing === false)
3913-
) {
3905+
if (actingUpdatesScopeDepth === 1) {
39143906
// we're about to exit the act() scope,
39153907
// now's the time to flush effects
39163908
flushActWork();

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3593,7 +3593,6 @@ function shouldForceFlushFallbacksInDEV() {
35933593
}
35943594

35953595
const flushMockScheduler = Scheduler.unstable_flushAllWithoutAsserting;
3596-
const isSchedulerMocked = typeof flushMockScheduler === 'function';
35973596

35983597
// Returns whether additional work was scheduled. Caller should keep flushing
35993598
// until there's no work left.
@@ -3723,11 +3722,7 @@ export function act(callback: () => Thenable<mixed>): Thenable<void> {
37233722
called = true;
37243723
result.then(
37253724
() => {
3726-
if (
3727-
actingUpdatesScopeDepth > 1 ||
3728-
(isSchedulerMocked === true &&
3729-
previousIsSomeRendererActing === true)
3730-
) {
3725+
if (actingUpdatesScopeDepth > 1) {
37313726
onDone();
37323727
resolve();
37333728
return;
@@ -3763,10 +3758,7 @@ export function act(callback: () => Thenable<mixed>): Thenable<void> {
37633758

37643759
// flush effects until none remain, and cleanup
37653760
try {
3766-
if (
3767-
actingUpdatesScopeDepth === 1 &&
3768-
(isSchedulerMocked === false || previousIsSomeRendererActing === false)
3769-
) {
3761+
if (actingUpdatesScopeDepth === 1) {
37703762
// we're about to exit the act() scope,
37713763
// now's the time to flush effects
37723764
flushActWork();

0 commit comments

Comments
 (0)