noRenderReturnValue
Summary
Section titled “Summary”- Rule available since:
v1.0.0 - Diagnostic Category:
lint/correctness/noRenderReturnValue - This rule doesn’t have a fix.
- The default severity of this rule is error.
- This rule belongs to the following domains:
How to configure
Section titled “How to configure”{ "linter": { "rules": { "correctness": { "noRenderReturnValue": "error" } } }}Description
Section titled “Description”Prevent the usage of the return value of React.render.
ReactDOM.render()currently returns a reference to the rootReactComponentinstance. 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 rootReactComponentinstance, the preferred solution is to attach a callback ref to the root element.
Source: ReactDOM documentation
Examples
Section titled “Examples”Invalid
Section titled “Invalid”const foo = ReactDOM.render(<div />, document.body);code-block.jsx:1:13 lint/correctness/noRenderReturnValue ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Do not depend on the value returned by the function ReactDOM.render().
> 1 │ const foo = ReactDOM.render(<div />, document.body);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ The returned value is legacy and future versions of React might return that value asynchronously.
Check the React documentation for more information.
ReactDOM.render(<div />, document.body);Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.