In React, the ReactDOM.render()
method is used to render a React component into a DOM element. It has a return value, but it’s
generally recommended not to use it. The method might return a reference to the root ReactComponent
instance, but it can be unpredictable
and may not always be useful. Indeed, the return value can vary depending on the version of React you’re using and the specific circumstances in which
it’s called.
const instance = ReactDOM.render(<App />, document.body); // Noncompliant: using the return value of 'ReactDOM.render'
doSomething(instance);
ReactDOM.render(<App />, document.body);
Alternatively, if you really need a reference to the root ReactComponent
instance, the preferred solution is to attach a "callback
ref" to the root element.
ReactDOM.render(<App />, document.body, callbackRef);