Using the return value of ReactDOM.render()
should be avoided
- REACT_ASYNC_RENDER_RETURN_VALUE
- Code Quality
- Low
- react
This rule applies when the return value of ReactDOM.render()
is used.
ReactDOM.render()
currently returns a reference to the root React component instance. However, using this return value is legacy and should be avoided because future versions of React may render components asynchronously in some cases.
For more information, please see ReactDOM.render().
Note: This rule is based on React 17 API specifications.
Noncompliant Code Example
View with compliant examples side by sideimport ReactDOM from 'react-dom';
doSomething(ReactDOM.render(<App />, rootElement)); // REACT_ASYNC_RENDER_RETURN_VALUE alarm
Compliant Code Example
View with noncompliant examples side by sideimport ReactDOM from 'react-dom';
// Attach a callback ref to get a return value
ReactDOM.render(<App ref={doSomething} />, rootElement);
Version
This rule was introduced in DeepScan 1.2.0-alpha.