Skip to content

Commit 5c306e6

Browse files
gaearonsophiebits
authored andcommitted
Add another (failing) regression test for #14188
1 parent 8df4d59 commit 5c306e6

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,48 @@ describe('ReactDOMSuspensePlaceholder', () => {
222222
await Lazy;
223223
expect(log).toEqual(['cDU first', 'cDU second']);
224224
});
225+
226+
// Regression test for https://github.com/facebook/react/issues/14188
227+
it('can call findDOMNode() in a suspended component commit phase (#2)', () => {
228+
let suspendOnce = Promise.resolve();
229+
function Suspend() {
230+
if (suspendOnce) {
231+
let promise = suspendOnce;
232+
suspendOnce = null;
233+
throw promise;
234+
}
235+
return null;
236+
}
237+
238+
const log = [];
239+
class Child extends React.Component {
240+
componentDidMount() {
241+
log.push('cDM');
242+
ReactDOM.findDOMNode(this);
243+
}
244+
245+
componentDidUpdate() {
246+
log.push('cDU');
247+
ReactDOM.findDOMNode(this);
248+
}
249+
250+
render() {
251+
return null;
252+
}
253+
}
254+
255+
function App() {
256+
return (
257+
<Suspense fallback="Loading">
258+
<Suspend />
259+
<Child />
260+
</Suspense>
261+
);
262+
}
263+
264+
ReactDOM.render(<App />, container);
265+
// expect(log).toEqual([]);
266+
ReactDOM.render(<App />, container);
267+
// expect(log).toEqual(['cDM']);
268+
});
225269
});

0 commit comments

Comments
 (0)