function app() {
const html_str = '<h1 style="color:red;">something</h1>';
return (
<div dangerouslySetInnerHTML={{ __html: html_str }} />
);
}
The code example above is a function that returns a div element. The div element has a property called dangerouslySetInnerHTML. The value of this property is set to an object with a key of __html and a value of html_str. The html_str variable is a string that contains HTML. This allows the HTML to be rendered as part of the div element.
0 Comments