Skip to content

Commit a4cef29

Browse files
raunofreiberggaearon
authored andcommitted
tests: add regression test for reading ReactCurrentOwner stateNode (#12412)
* tests: add regression test for reading ReactCurrentOwner stateNode * tests: replace expect with just rendering the component
1 parent 1591c8e commit a4cef29

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,26 @@ describe('ReactDOM', () => {
377377
}
378378
});
379379

380+
it('should not crash calling findDOMNode inside a functional component', () => {
381+
const container = document.createElement('div');
382+
383+
class Component extends React.Component {
384+
render() {
385+
return <div />;
386+
}
387+
}
388+
389+
const instance = ReactTestUtils.renderIntoDocument(<Component />);
390+
const App = () => {
391+
ReactDOM.findDOMNode(instance);
392+
return <div />;
393+
};
394+
395+
if (__DEV__) {
396+
ReactDOM.render(<App />, container);
397+
}
398+
});
399+
380400
it('throws in DEV if jsdom is destroyed by the time setState() is called', () => {
381401
class App extends React.Component {
382402
state = {x: 1};

0 commit comments

Comments
 (0)