Skip to content

Commit

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

* tests: add regression test for reading ReactCurrentOwner stateNode

* tests: replace expect with just rendering the component
  • Loading branch information
raunofreiberg authored and rhagigi committed Apr 19, 2018
1 parent 4b1599c commit 6e0edcc
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 6e0edcc

Please sign in to comment.