Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • Do not follow such approaches dangerouslySetInnerHTML is React’s replacement for using innerHTML in the browser DOM but setting HTML from code is risky because it’s easy to inadvertently expose your users to a cross-site scripting (XSS) attack. Commented Feb 5, 2022 at 3:53
  • 1
    @NevetsKuro there's no risk when injecting a string literal like this, only if you have user input variables. Commented Feb 5, 2022 at 7:24
  • Yes my bad. It is for the case for user input only. But you need to mention that in this solution, as React keeps popping this as a bug/warning. Ref: pragmaticwebsecurity.com/articles/spasecurity/… Commented Feb 7, 2022 at 6:41