Skip to content

Commit

Permalink
Fix findCurrentFiberUsingSlowPath w/ no alternate
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiebits committed Dec 6, 2018
1 parent 5c306e6 commit 6a7d3a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ describe('ReactDOMSuspensePlaceholder', () => {
}

ReactDOM.render(<App />, container);
// expect(log).toEqual([]);
expect(log).toEqual(['cDM']);
ReactDOM.render(<App />, container);
// expect(log).toEqual(['cDM']);
expect(log).toEqual(['cDM', 'cDU']);
});
});
13 changes: 7 additions & 6 deletions packages/react-reconciler/src/ReactFiberTreeReflection.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,17 @@ export function findCurrentFiberUsingSlowPath(fiber: Fiber): Fiber | null {
let b = alternate;
while (true) {
let parentA = a.return;
let parentB = parentA ? parentA.alternate : null;
if (!parentA || !parentB) {
if (!parentA) {
// We're at the root.
break;
}

// If both copies of the parent fiber point to the same child, we can
// assume that the child is current. This happens when we bailout on low
// priority: the bailed out fiber's child reuses the current child.
if (parentA.child === parentB.child) {
// If both copies of the parent fiber point to the same child (or if there
// is only a single parent fiber), we can assume that the child is current.
// This happens when we bailout on low priority: the bailed out fiber's
// child reuses the current child.
let parentB = parentA.alternate;
if (parentB === null || parentA.child === parentB.child) {
let child = parentA.child;
while (child) {
if (child === a) {
Expand Down

0 comments on commit 6a7d3a0

Please sign in to comment.