I am trying to display HTML content on React front side.
Here is my input
<p>Hello/<p>
Aadafsf
<h1>H1 in hello</h1>
I write this from CKEditor from Admin side
This is the React result in front size
<p>Hello/<p>
Aadafsf
<h1>H1 in hello</h1>
This is the result I would like
<p>Hello/<p>
Aadafsf
<h1>H1 in hello</h1>
Here is what I tried so far
1. Using dompurify
import {Parser} from "html-to-react";
import DOMPurify from "dompurify";
{Parser().parse(DOMPurify.sanitize(HTMLCONTENT))}
I tried this but I'm not getting the expected output.
2. Using dangerouslySetInnerHTML
I have the below HTML content:
<h2>This is Heading</h2><p><p></p></p><p>This is para.</p><p> </p><p><strong>This is Bold</strong></p><p> </p><ol><li><strong>dwsfdf</strong></li><li><strong>fdsfdf</strong></li></ol><p> </p><p> </p><p> </p><figure class="media"><oembed url="https://youtu.be/rokGy0huYEA"></oembed></figure>
I used it like:
<div dangerouslySetInnerHTML={{__html: HTMLCONTENT}} />;
