To render HTML string as real HTML with React, we use the dangerouslySetInnerHTML
prop.
For instance, we write
<div dangerouslySetInnerHTML={{ __html: htmlString }} />;
to add a div with the dangerouslySetInnerHTML
prop set to an object with the __html
property set to the htmlString
string.
Then htmlString
is rendered as HTML.