0

So I'm currently building a blogpost and the entire 'post' of this JSON file contains HTML in it, things like <p></p> or <br> and such. What's the most efficient way to place this in my ReactApp? I have no trouble getting everything else in but have no clue how to handle the 'post' part since different articles may have <br> and such in different areas and would like to avoid using dangerouslySetInnerHTML or at least find a safe way of using it.

kittykittybangbang
  • 2,380
  • 4
  • 16
  • 27
Matt Nguyen
  • 1
  • 2
  • 1

1 Answers1

3

You can use DOMPurify to sanitize your HTML before inserting it in the DOM via dangerouslySetInnerHTML. Hope it works!

Robert
  • 5,278
  • 43
  • 65
  • 115
Albert Olivé Corbella
  • 4,061
  • 7
  • 48
  • 66