Skip to main content

react/noRenderReturnValue

prevent usage of the return value of React.render

ESLint Equivalent: no-render-return-value

Examples

Invalid

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

 file.tsx:1:12 lint/react/noRenderReturnValue ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Do not depend on the return value from ReactDOM.render().

    const foo = ReactDOM.render(<div />, document.body);
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


const foo = bar && ReactDOM.render(<div />, document.body);

 file.tsx:1:19 lint/react/noRenderReturnValue ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Do not depend on the return value from ReactDOM.render().

    const foo = bar && ReactDOM.render(<div />, document.body);
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


const foo = bar ? ReactDOM.render(<div />, document.body) : null

 file.tsx:1:18 lint/react/noRenderReturnValue ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Do not depend on the return value from ReactDOM.render().

    const foo = bar ? ReactDOM.render(<div />, document.body) : null
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


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

 file.tsx:1:18 lint/react/noRenderReturnValue ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Do not depend on the return value from ReactDOM.render().

    const foo = () => ReactDOM.render(<div />, document.body);
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


const foo = {
	react: ReactDOM.render(<div />, document.body)
};

 file.tsx:2:8 lint/react/noRenderReturnValue ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Do not depend on the return value from ReactDOM.render().

    1const foo = {
  > 2  react: ReactDOM.render(<div />, document.body)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    3};


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

 file.tsx:2:6 lint/react/noRenderReturnValue ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Do not depend on the return value from ReactDOM.render().

    1let foo;
  > 2foo = ReactDOM.render(<div />, document.body);
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


function render () {
	return ReactDOM.render(<div />, document.body)
}

 file.tsx:2:8 lint/react/noRenderReturnValue ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Do not depend on the return value from ReactDOM.render().

    1function render () {
  > 2  return ReactDOM.render(<div />, document.body)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    3}

Valid

ReactDOM.render(<div />, document.body);
function render () {
	ReactDOM.render(<div />, document.body);
}
const render = () => {
	ReactDOM.render(<div />, document.body);
}