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

Fix undefined DOM element at transition group #6744

Closed
wants to merge 1 commit into from
Closed

Fix undefined DOM element at transition group #6744

wants to merge 1 commit into from

Conversation

malstoun
Copy link

It relates to #6619. Since isMounted() 'will likely be removed entirely in a future version of React' (according to this) maybe it would be better use findDOMNode to check whether element has node or not.

findDOMNode returns null if in render method we return null or false (e.g. to hide element), otherwise we have node to make some manipulation with it.

@jimfb
Copy link
Contributor

jimfb commented May 11, 2016

Using findDOMNode is just as bad as using isMounted. If you feel the need to check, your code is already smelly "because the only reason you would check is because you think you might be holding a reference after the component has unmounted" (https://facebook.github.io/react/blog/2015/12/16/ismounted-antipattern.html).

If anything, this suggests to me that findDOMNode should also warn if called on an unmounted component. It's literally just as bad as doing a setState on an unmounted component.

The correct solution would be to drop references in componentWillUnmount. It appears that componentWillUnmount already clears all the timers. Why is this isMounted logic necessary in the first place?

@keyz
Copy link
Contributor

keyz commented Jun 3, 2016

Fixed in #6958. Thanks @malstoun!

@keyz keyz closed this Jun 3, 2016
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.

3 participants