-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Hard to use with CSS-in-JS libs. #793
Description
Background
I'm currently using Netlify CMS to build a website for a client. It's a completely static site, but it uses React as a template engine. I also use the React bundle to render a preview inside Netlify CMS.
The other important detail is that this website is styled with styled-components, which works by injecting css rules into document.getElementsByTagName('head')[0].
The Problem
Netlify CMS transplants the preview component inside an iframe, while the <style> elements generated by styled-components remain outside the iframe. This leaves me with an unstyled preview, which is most unappealing. ✨
I haven't tested, but I expect this to affect other CSS-in-JS libraries like Glamorous, jsxstyle, or JSS as well as any other React library that injects extra elements, like react-helmet or react-portal.