Lint Rules

noRenderReturnValue (since v0.10.0)

This rule is recommended by Rome.

Prevent the usage of the return value of React.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.

Source: ReactDOM documentation

Examples

Invalid

const foo = ReactDOM.render(<div />, document.body);
correctness/noRenderReturnValue.js: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.
  

Valid

ReactDOM.render(<div />, document.body);