arrow_backBACK TO DRILLS
Blue BeltrenderingPREMIUM
dangerouslySetInnerHTML Cannot Render a Full HTML Document
This component injects a complete HTML document string, including html, head, and body tags, into a div using dangerouslySetInnerHTML. The content renders blank, and any script tags inside the string never execute.
REACT_MODULE // 0x42
function EmbeddedContent({ html }) {
return <div dangerouslySetInnerHTML={{ __html: html }} />;
}
const fullDocument = "<html><head><title>Doc</title></head><body><p>Content</p></body></html>";
<EmbeddedContent html={fullDocument} />Why does passing a full HTML document string here fail to render the content?