How to render element rather than string?
Closed this issue · 2 comments
johnknoop commented
I though I could use this library instead of dangerouslySetInnerHtml
, but the sample code from the readme just returns a string, which React will escape.
rudfoss commented
import HtmlToReact from "html-to-react"
var htmlInput = '<div><h1>Title</h1><p>A paragraph</p></div>';
const parser = new HtmlToReact.Parser()
var reactElement = parser.parse(htmlInput);
const Component = () => {
return (
<div>{reactElement}</div>
)
}