diff --git a/packages/react-dom/src/__tests__/ReactDOMSuspensePlaceholder-test.internal.js b/packages/react-dom/src/__tests__/ReactDOMSuspensePlaceholder-test.internal.js
index 98069e2d9f40..9536460d9fff 100644
--- a/packages/react-dom/src/__tests__/ReactDOMSuspensePlaceholder-test.internal.js
+++ b/packages/react-dom/src/__tests__/ReactDOMSuspensePlaceholder-test.internal.js
@@ -222,4 +222,48 @@ describe('ReactDOMSuspensePlaceholder', () => {
await Lazy;
expect(log).toEqual(['cDU first', 'cDU second']);
});
+
+ // Regression test for https://github.com/facebook/react/issues/14188
+ it('can call findDOMNode() in a suspended component commit phase (#2)', () => {
+ let suspendOnce = Promise.resolve();
+ function Suspend() {
+ if (suspendOnce) {
+ let promise = suspendOnce;
+ suspendOnce = null;
+ throw promise;
+ }
+ return null;
+ }
+
+ const log = [];
+ class Child extends React.Component {
+ componentDidMount() {
+ log.push('cDM');
+ ReactDOM.findDOMNode(this);
+ }
+
+ componentDidUpdate() {
+ log.push('cDU');
+ ReactDOM.findDOMNode(this);
+ }
+
+ render() {
+ return null;
+ }
+ }
+
+ function App() {
+ return (
+
+
+
+
+ );
+ }
+
+ ReactDOM.render(, container);
+ expect(log).toEqual(['cDM']);
+ ReactDOM.render(, container);
+ expect(log).toEqual(['cDM', 'cDU']);
+ });
});
diff --git a/packages/react-reconciler/src/ReactFiberTreeReflection.js b/packages/react-reconciler/src/ReactFiberTreeReflection.js
index f2c3e37b699e..dfb4c5532367 100644
--- a/packages/react-reconciler/src/ReactFiberTreeReflection.js
+++ b/packages/react-reconciler/src/ReactFiberTreeReflection.js
@@ -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) {