createPortal and emotion in a gatsby site is not working
See original GitHub issueI am opening this issue as a duplicated one I’ve just posted in gatsby
, since I don’t know where it belongs
I think it is a gatsby issue, but I’m opening this one just to be sure
Here https://github.com/gatsbyjs/gatsby/issues/27352 I am using createPortal
as seen here
- https://stackoverflow.com/a/34744946/826815 and in the linked codesandbox
- https://codesandbox.io/s/react-iframe-examples-forked-jsn98?file=/src/examples/with-emotion.js
And when embedded in gatsby
, it works in gatsby development
but not in gatsby build
This happens with and without the @emotion
plugins
"plugins": ["emotion", "@babel/plugin-proposal-class-properties"]
So I’m not sure who is responsible, whether gatsby or emotion 😅
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
How to render a React component styled with Emotion in an ...
Components are styled using Emotion and the demo site is built with Gatsby. For preview purposes, I'd like to render components in an...
Read more >gatsby-plugin-portal
If you want to use React Portals in your gatsby site, this is a simple way to add the required div element to...
Read more >How to render a React component styled with Emotion in an ...
Coding example for the question How to render a React component styled with Emotion in an iframe in Gatsby site?-Reactjs.
Read more >Accessible modals in Gatsby using portals - Level Up Coding
Adding a modal (dialog) to your website or app is a common scenario. ... could cause issues with positioning (z-index, overflow: hidden).
Read more >gatsby-theme-newrelic - npm
This theme contains contains common configuration and shared components used across New Relic Gatsby sites. It is primarily used on the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh, I’ve focused on the iframe and not on the main page itself 🤦 The fix is simple - just add a custom
key
option when creating that custom cache. We’ve already added an error about this in the upcoming Emotion 11: https://github.com/emotion-js/emotion/blob/ff4ee9d1623c2ad15a6ce9fa7a81ee8809683dad/packages/cache/src/index.js#L48-L53This happens because the development workflow doesn’t use SSR and at the time of cache creation there are no style elements on the page, however when you are using SSR there are already style elements there and because the same default cache key has been used for both the builtin and custom caches they fought over those elements and the second cache created (the custom one) moved those style elements into the iframe and thus removing them from the main page and leaving it unstyled.
How to add a custom key option?