简体   繁体   中英

Facebook React: Uncaught Error: Invariant Violation: getDOMNode(): A component must be mounted to have a DOM node

I have the following error within reactjs internals:

Uncaught Error: Invariant Violation: getDOMNode(): A component must be mounted to have a DOM node

What does it mean? What can I do about it?

the stack trace:

invariantDev react.js:14392
ReactComponentBrowserEnvironment.Mixin.getDOMNode react.js:4072
React.createClass.scrollToBottom app.js:14124
(anonymous function)

This means that you're using getDOMNode before the component has been rendered in the DOM.

You can use componentDidMount to wait to run code until the component has been mounted:

componentDidMount() {
    // do stuff here that requires the DOM to exist
}

you can read more here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM