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
Rauno Freiberg committed
Apr 16, 2018 at 17:44 UTC
a4cef2970341c08e5c16a2406fbf532fc8053d12
1 file changed
+20
packages/react-dom/src/__tests__/ReactDOM-test.js
+20
@@ -377,6 +377,26 @@ describe('ReactDOM', () => {
377
}
378
});
379
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
+
400
it('throws in DEV if jsdom is destroyed by the time setState() is called', () => {
401
class App extends React.Component {
402
state = {x: 1};