Skip to content

Commit d5df61c

Browse files
committed
Add a mutually recursive test case
1 parent 63c3456 commit d5df61c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

packages/react-dom/src/__tests__/ReactUpdates-test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,6 +1417,32 @@ describe('ReactUpdates', () => {
14171417
expect(container.textContent).toBe('1');
14181418
});
14191419

1420+
it('does not fall into mutually recursive infinite update loop', () => {
1421+
class A extends React.Component {
1422+
state = {step: 0};
1423+
componentDidMount() {
1424+
ReactDOM.render(<B />, container);
1425+
}
1426+
render() {
1427+
return null;
1428+
}
1429+
}
1430+
1431+
class B extends React.Component {
1432+
componentDidMount() {
1433+
ReactDOM.render(<A />, container);
1434+
}
1435+
render() {
1436+
return null;
1437+
}
1438+
}
1439+
1440+
const container = document.createElement('div');
1441+
expect(() => {
1442+
ReactDOM.render(<A />, container);
1443+
}).toThrow('Maximum');
1444+
});
1445+
14201446
it('does not fall into an infinite error loop', () => {
14211447
function BadRender() {
14221448
throw new Error('error');

0 commit comments

Comments
 (0)