Skip to content

Commit

Permalink
tests: add regression test for reading ReactCurrentOwner stateNode (#…
Browse files Browse the repository at this point in the history
…12412)

* tests: add regression test for reading ReactCurrentOwner stateNode

* tests: replace expect with just rendering the component
  • Loading branch information
raunofreiberg authored and gaearon committed Apr 16, 2018
1 parent 1591c8e commit a4cef29
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/react-dom/src/__tests__/ReactDOM-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,26 @@ describe('ReactDOM', () => {
}
});

it('should not crash calling findDOMNode inside a functional component', () => {
const container = document.createElement('div');

class Component extends React.Component {
render() {
return <div />;
}
}

const instance = ReactTestUtils.renderIntoDocument(<Component />);
const App = () => {
ReactDOM.findDOMNode(instance);
return <div />;
};

if (__DEV__) {
ReactDOM.render(<App />, container);
}
});

it('throws in DEV if jsdom is destroyed by the time setState() is called', () => {
class App extends React.Component {
state = {x: 1};
Expand Down

0 comments on commit a4cef29

Please sign in to comment.