After fetching richtext editor's data from backend with reactJs the text display with HTML tag inside my div.
fetched data was such as:
const richText = '<p>Hello<strong> World</strong></p><p><strong>Next Line</strong></p>';
Now I want to "Render" the richText in a REACT component as such:
Hello World
Next Line
Step 1:
npm i dompurifyStep 2:
import DOMPurify from 'dompurify'inside your component where you want to display data:
<div dangerouslySetInnerHTML={{__html:DOMPurify.sanitize(richText)}} > </div>