Cryptic error message for findDOMNode of unmounted component
See original GitHub issueAs per https://github.com/facebook/react/issues/2410#issuecomment-115659185: findDOMNode(this) throws for unmounted components, but the error message is too cryptic:
Uncaught Error: Invariant Violation: Component (with keys: getDOMNode,_handleChange,props,context,state,refs,_reactInternalInstance) contains render method but is not mounted in the DOM
Some expert React users honestly thought they had duplicate React or something, so didn’t even bother to check whether the component was mounted. (It wasn’t.)
Issue Analytics
- State:
- Created 8 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
React 16: Error: Unable to find node on an unmounted ...
Based on the error message, I believe the error is happening when calling ReactDOM.findDOMNode(this) in the handleClickOutside(event) method.
Read more >Blog | React - GitHub Pages
findDOMNode (see below). If your components are currently using .getDOMNode() , they will continue to work with a warning until 0.15.
Read more >Getting rid of findDOMNode in your React application - Medium
This ReactDOM method allows us to access the underlying DOM node of a component. As we can see, findDOMNode is deprecated in StrictMode....
Read more >Getting large cryptic errors and warnings when trying to use ...
Coding example for the question Getting large cryptic errors and warnings when trying to use mongoose with webpack-Reactjs.
Read more >find_element_by_tag_name is deprecated - You.com | The AI ...
Previously, runtime errors used to put React into a broken state and produce cryptic errors. React 16 fixes this by introducing a special...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For any who may happen to run across this same error in the future, I recently saw this error which was caused by calling
getDOMNode()
on a component that had been unmounted. This was caused by an asynchronous event that then assumed the component was still mounted. AlthoughisMounted
is considered an anti-pattern, this is one possible use case that I see it being very convenient for.Got it, thanks. I was just worried we missed some case when adding a warning.