2

I'm currently using :

<div dangerouslySetInnerHTML={{ __html: article.content }}></div>

in order to render the rich text I get from a CKEditor input field from a Strapi CMS backend. Is there a better way to do this that doesn't use dangerouslySetInnerHTML? I've looked into ReactMarkdown, but that seems to only work with Strapi's built-in old Markdown editor.

Blue Moon
  • 79
  • 1
  • 9

2 Answers2

1

Use html-react-parser library to have more control. You will be able to change dom elements, attributes, classes,...

0

In our project we are using dangerouslySetInnerHTML as well.

Ruslan Korkin
  • 3,973
  • 1
  • 27
  • 23
  • with dangerouslySetInnerHTML you loose the optimisation of Image tag porvided by NextJs even the Link features. that's why he does not want to use dangerouslySetInnerHTML – Moussaabmma Apr 09 '23 at 21:36