Skip to content

Commit

Permalink
fixed unfound node error when Suspense is filtered
Browse files Browse the repository at this point in the history
  • Loading branch information
IDrissAitHafid committed Oct 14, 2020
1 parent e614e69 commit 4e308e4
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion packages/react-devtools-shared/src/backend/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1437,6 +1437,9 @@ export function attach(
}

function recordResetChildren(fiber: Fiber, childSet: Fiber) {
if (__DEBUG__) {
debug('recordResetChildren()', childSet, fiber);
}
// The frontend only really cares about the displayName, key, and children.
// The first two don't really change, so we are only concerned with the order of children here.
// This is trickier than a simple comparison though, since certain types of fibers are filtered.
Expand Down Expand Up @@ -1471,6 +1474,23 @@ export function attach(
nextChildren.push(getFiberID(getPrimaryFiber(fiber)));
} else {
let child = fiber.child;
const isTimedOutSuspense =
fiber.tag === SuspenseComponent && fiber.memoizedState !== null;
if (isTimedOutSuspense) {
// Special case: if Suspense mounts in a timed-out state,
// get the fallback child from the inner fragment,
// and skip over the primary child.
const primaryChildFragment = fiber.child;
const fallbackChildFragment = primaryChildFragment
? primaryChildFragment.sibling
: null;
const fallbackChild = fallbackChildFragment
? fallbackChildFragment.child
: null;
if (fallbackChild !== null) {
child = fallbackChild;
}
}
while (child !== null) {
findReorderedChildrenRecursively(child, nextChildren);
child = child.sibling;
Expand Down Expand Up @@ -1592,7 +1612,7 @@ export function attach(
if (nextFallbackChildSet != null) {
mountFiberRecursively(
nextFallbackChildSet,
nextFiber,
shouldIncludeInTree ? nextFiber : parentFiber,
true,
traceNearestHostComponentUpdate,
);
Expand Down

0 comments on commit 4e308e4

Please sign in to comment.