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,344
  • 4
  • 15
  • 26
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,231
  • 43
  • 62
  • 114
Albert Olivé
  • 3,781
  • 6
  • 45
  • 64