Skip to content

Commit 9805935

Browse files
committed
fix suspense throttling
1 parent b8cfda1 commit 9805935

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,22 +2250,25 @@ function commitMutationEffectsOnFiber(
22502250
}
22512251
}
22522252

2253-
if (flags & Visibility) {
2254-
switch (finishedWork.tag) {
2255-
case SuspenseComponent: {
2256-
const newState: OffscreenState | null = finishedWork.memoizedState;
2253+
switch (finishedWork.tag) {
2254+
case SuspenseComponent: {
2255+
const offscreenFiber: Fiber = (finishedWork.child: any);
2256+
if (offscreenFiber.flags & Visibility) {
2257+
const newState: OffscreenState | null = offscreenFiber.memoizedState;
22572258
const isHidden = newState !== null;
22582259
if (isHidden) {
2259-
const current = finishedWork.alternate;
2260+
const current = offscreenFiber.alternate;
22602261
const wasHidden = current !== null && current.memoizedState !== null;
22612262
if (!wasHidden) {
22622263
// TODO: Move to passive phase
22632264
markCommitTimeOfFallback();
22642265
}
22652266
}
2266-
break;
22672267
}
2268-
case OffscreenComponent: {
2268+
break;
2269+
}
2270+
case OffscreenComponent: {
2271+
if (flags & Visibility) {
22692272
const newState: OffscreenState | null = finishedWork.memoizedState;
22702273
const isHidden = newState !== null;
22712274
const current = finishedWork.alternate;
@@ -2301,7 +2304,6 @@ function commitMutationEffectsOnFiber(
23012304
}
23022305
}
23032306
}
2304-
23052307
// The following switch statement is only concerned about placement,
23062308
// updates, and deletions. To avoid needing to add a case for every possible
23072309
// bitmap value, we remove the secondary effects from the effect tag and

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,22 +2250,25 @@ function commitMutationEffectsOnFiber(
22502250
}
22512251
}
22522252

2253-
if (flags & Visibility) {
2254-
switch (finishedWork.tag) {
2255-
case SuspenseComponent: {
2256-
const newState: OffscreenState | null = finishedWork.memoizedState;
2253+
switch (finishedWork.tag) {
2254+
case SuspenseComponent: {
2255+
const offscreenFiber: Fiber = (finishedWork.child: any);
2256+
if (offscreenFiber.flags & Visibility) {
2257+
const newState: OffscreenState | null = offscreenFiber.memoizedState;
22572258
const isHidden = newState !== null;
22582259
if (isHidden) {
2259-
const current = finishedWork.alternate;
2260+
const current = offscreenFiber.alternate;
22602261
const wasHidden = current !== null && current.memoizedState !== null;
22612262
if (!wasHidden) {
22622263
// TODO: Move to passive phase
22632264
markCommitTimeOfFallback();
22642265
}
22652266
}
2266-
break;
22672267
}
2268-
case OffscreenComponent: {
2268+
break;
2269+
}
2270+
case OffscreenComponent: {
2271+
if (flags & Visibility) {
22692272
const newState: OffscreenState | null = finishedWork.memoizedState;
22702273
const isHidden = newState !== null;
22712274
const current = finishedWork.alternate;
@@ -2301,7 +2304,6 @@ function commitMutationEffectsOnFiber(
23012304
}
23022305
}
23032306
}
2304-
23052307
// The following switch statement is only concerned about placement,
23062308
// updates, and deletions. To avoid needing to add a case for every possible
23072309
// bitmap value, we remove the secondary effects from the effect tag and

0 commit comments

Comments
 (0)