Skip to content

Commit 6a7d3a0

Browse files
committed
Fix findCurrentFiberUsingSlowPath w/ no alternate
1 parent 5c306e6 commit 6a7d3a0

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

packages/react-dom/src/__tests__/ReactDOMSuspensePlaceholder-test.internal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ describe('ReactDOMSuspensePlaceholder', () => {
262262
}
263263

264264
ReactDOM.render(<App />, container);
265-
// expect(log).toEqual([]);
265+
expect(log).toEqual(['cDM']);
266266
ReactDOM.render(<App />, container);
267-
// expect(log).toEqual(['cDM']);
267+
expect(log).toEqual(['cDM', 'cDU']);
268268
});
269269
});

packages/react-reconciler/src/ReactFiberTreeReflection.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,17 @@ export function findCurrentFiberUsingSlowPath(fiber: Fiber): Fiber | null {
117117
let b = alternate;
118118
while (true) {
119119
let parentA = a.return;
120-
let parentB = parentA ? parentA.alternate : null;
121-
if (!parentA || !parentB) {
120+
if (!parentA) {
122121
// We're at the root.
123122
break;
124123
}
125124

126-
// If both copies of the parent fiber point to the same child, we can
127-
// assume that the child is current. This happens when we bailout on low
128-
// priority: the bailed out fiber's child reuses the current child.
129-
if (parentA.child === parentB.child) {
125+
// If both copies of the parent fiber point to the same child (or if there
126+
// is only a single parent fiber), we can assume that the child is current.
127+
// This happens when we bailout on low priority: the bailed out fiber's
128+
// child reuses the current child.
129+
let parentB = parentA.alternate;
130+
if (parentB === null || parentA.child === parentB.child) {
130131
let child = parentA.child;
131132
while (child) {
132133
if (child === a) {

0 commit comments

Comments
 (0)