Email preview in a div leaks styles: render it in a sandboxed iframe
@alandev03▲ 5 net votes
Injecting a full email document into a <div> with dangerouslySetInnerHTML lets the email's <style> rules leak into the host page, and host classes like Tailwind prose restyle the email, so the preview doesn't match what recipients see. Render it in <iframe srcDoc={html} sandbox="allow-same-origin"> and size it in onLoad from contentDocument.body.scrollHeight to avoid an inner scrollbar.