Don't use the return value of the 'ReactDOM.render()' method |
When working with the 'ReactDOM.render()' method don't use its return value
CheckId | RCT010111 |
---|---|
TypeName | ReactDOMRenderRule |
Severity | Warning |
Type | TypeScript file |
When working with the ReactDOM.render() method don't use its return value. It's considered deprecated and could be removed in the future. If you need to get the result of rendering, use a callback instead.
Bad practice
const app = ReactDOM.render(<App />, container);
doSomething(app);
doSomething(app);
Good practice
function doSomething(app) {
}
ReactDOM.render(<App ref={doSomething} />, container);
}
ReactDOM.render(<App ref={doSomething} />, container);
Disclaimer: The views and opinions expressed in this documentation and in SPCAF do not necessarily reflect the opinions and recommendations of Microsoft or any member of Microsoft. SPCAF and RENCORE are registered trademarks of Rencore. All other trademarks, service marks, collective marks, copyrights, registered names, and marks used or cited by this documentation are the property of their respective owners.