Skip to content

Commit

Permalink
fix suspense throttling
Browse files Browse the repository at this point in the history
  • Loading branch information
sunderls committed Apr 1, 2022
1 parent b8cfda1 commit fd70a75
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
18 changes: 10 additions & 8 deletions packages/react-reconciler/src/ReactFiberCommitWork.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -2250,22 +2250,25 @@ function commitMutationEffectsOnFiber(
}
}

if (flags & Visibility) {
switch (finishedWork.tag) {
case SuspenseComponent: {
const newState: OffscreenState | null = finishedWork.memoizedState;
switch (finishedWork.tag) {
case SuspenseComponent: {
const offscreenFiber: Fiber = (finishedWork.child: any);
if (offscreenFiber.flags & Visibility) {
const newState: OffscreenState | null = offscreenFiber.memoizedState;
const isHidden = newState !== null;
if (isHidden) {
const current = finishedWork.alternate;
const current = offscreenFiber.alternate;
const wasHidden = current !== null && current.memoizedState !== null;
if (!wasHidden) {
// TODO: Move to passive phase
markCommitTimeOfFallback();
}
}
break;
}
case OffscreenComponent: {
break;
}
case OffscreenComponent: {
if (flags & Visibility) {
const newState: OffscreenState | null = finishedWork.memoizedState;
const isHidden = newState !== null;
const current = finishedWork.alternate;
Expand Down Expand Up @@ -2301,7 +2304,6 @@ function commitMutationEffectsOnFiber(
}
}
}

// The following switch statement is only concerned about placement,
// updates, and deletions. To avoid needing to add a case for every possible
// bitmap value, we remove the secondary effects from the effect tag and
Expand Down
20 changes: 12 additions & 8 deletions packages/react-reconciler/src/ReactFiberCommitWork.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -2249,23 +2249,27 @@ function commitMutationEffectsOnFiber(
}
}
}

if (flags & Visibility) {
switch (finishedWork.tag) {
case SuspenseComponent: {
const newState: OffscreenState | null = finishedWork.memoizedState;

switch (finishedWork.tag) {
case SuspenseComponent: {
console.log('finishedWork markCommitTimeOfFallback');
const offscreenFiber: Fiber = (finishedWork.child: any);
if (offscreenFiber.flags & Visibility) {
const newState: OffscreenState | null = offscreenFiber.memoizedState;
const isHidden = newState !== null;
if (isHidden) {
const current = finishedWork.alternate;
const current = offscreenFiber.alternate;
const wasHidden = current !== null && current.memoizedState !== null;
if (!wasHidden) {
// TODO: Move to passive phase
markCommitTimeOfFallback();
}
}
break;
}
case OffscreenComponent: {
break;
}
case OffscreenComponent: {
if (flags & Visibility) {
const newState: OffscreenState | null = finishedWork.memoizedState;
const isHidden = newState !== null;
const current = finishedWork.alternate;
Expand Down

0 comments on commit fd70a75

Please sign in to comment.