Expand Minimize

Don't pass HTML as a string to the 'dangerouslySetInnerHTML' property

To specify HTML to render using the 'dangerouslySetInnerHTML' use the '__html' property

CheckId RCT010104
TypeName DangerouslySetInnerHTMLRule
Severity Error
Type React component

To specify HTML to render using the dangerouslySetInnerHTML use the __html property and don't pass the HTML directly as a string.

Bad practice

    <div dangerouslySetInnerHTML={ "some html" }>
        <Message />
    </div>, document.getElementById("container")

Good practice
const html = "some html";
    <div dangerouslySetInnerHTML={{ __html: "some html" }} />,

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.