To avoid HTML escaping of text children when calling React.createElement
, we use the dangerouslySetInnerHTML
prop.
For instance, we write
const Component = () => (
<span dangerouslySetInnerHTML={{ __html: "><" }} />
);
ReactDOM.render(<Component />, document.getElementById("container"));
to create the Component
component that renders the "><"
as raw HTML by setting it as the value of __html
in the object that we set as the value of the dangerouslySetInnerHTML
prop.