Rules
no-render-return-value
Full Name in eslint-plugin-react-dom
Full Name in @eslint-react/eslint-plugin
Presets
dom
recommended
recommended-typescript
recommended-type-checked
Description
Disallow the return value of ReactDOM.render
.
ReactDOM.render()
currently returns a reference to the root ReactComponent instance. However, using this return value is legacy and should be avoided because future versions of React may render components asynchronously in some cases. If you need a reference to the root ReactComponent instance, the preferred solution is to attach a callback ref to the root element.
Examples
Failing
Passing
Implementation
Further Reading
See Also
- no-render
Replaces usages ofReactDom.render()
withcreateRoot(node).render()
.