Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test to verify findDOMNode does not throw in willMount #6305

Merged
merged 1 commit into from
Mar 25, 2016
Merged

Test to verify findDOMNode does not throw in willMount #6305

merged 1 commit into from
Mar 25, 2016

Conversation

maherbeg
Copy link
Contributor

Adds a test to prevent a regression of throwing an error when
calling findDOMNode(this) in a component's componentWillMount
function. This previously used to throw an invariant violation but
now does not any more.

Fixes #4999

it('findDOMNode should not throw an error when called within a component that is not mounted', function() {
var Bar = React.createClass({
componentWillMount: function() {
ReactDOM.findDOMNode(this);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we assert its return value here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in, add an expect call within componentWillMount? Sure!

Adds a test to prevent a regression of throwing an error when
calling `findDOMNode(this)` in a component's `componentWillMount`
function. This previously used to throw an invariant violation but
now does not any more.
@maherbeg
Copy link
Contributor Author

Done! re-review? @gaearon

@facebook-github-bot
Copy link

@maherbeg updated the pull request.

@jimfb jimfb merged commit dcd0925 into facebook:master Mar 25, 2016
@jimfb
Copy link
Contributor

jimfb commented Mar 25, 2016

Thanks @maherbeg!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants