I got HTML come from backend and I need to renderer it inside div or whatever works
I sanitize the HTML before show it up
import DOMPurify from "dompurify";
......
var cleanHtml = DOMPurify.sanitize( HtmlPassedFromBackEnd , {
FORBID_TAGS: ["style"],
});
then passing sanitized HTML to component <HtmlComponent template={cleanHtml} />
import React from "react";
export default class HtmlComponent extends React.Component {
render() {
return <div dangerouslySetInnerHTML={{__html: this.props.template }}/>
}
}
it's working fine in most cases but its failed in another example is there anything like webview I can safely render my HTML