-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[gatsby-plugin-styled-components]: Plugin not working properly with styled components v5 with SSR #24341
Comments
As the current version of gatsby-plugin-styled-components doesn’t seem to work with styled-components 5.x I needed to downgrade to get the SSR running again. Issue: gatsbyjs/gatsby#24341
As the current version of gatsby-plugin-styled-components doesn’t seem to work with styled-components 5.x I needed to downgrade to get the SSR running again. Issue: gatsbyjs/gatsby#24341
FYI -- faced this same issue today, resolved by using I validated locally with your repo @kogakure Not sure if this is indeed a bug or expected behavior of the plugin. |
The |
I moved |
Awesome! |
Hi sorry to bother, but i have a FOUC too. i had it before using wrapPageElement and now that i moved my global styles in wrapPageElement, i don't get those altogether. I tried the v4 but i have some error. i did look at kogakure commit kogakure/website-gatsby-stefanimhoff.de@9be078d but i can't succeed to make my style work |
@jocelinqueau Both examples throw errors. Without looking too deep into the code, try fixing this code in - export const wrapPageElement = ({element}) =>{
+ export const wrapPageElement = ({element}) =>(
<>
<Typographie />
<GlobalStyles />
{element}
</>
-}
+); |
@kogakure Yes, sorry about that. Thank for highlighting this for me. |
@jocelinqueau I’m glad I could help, keep the message, somebody else might learn from it. 👨💻 |
@kogakure, ok thanks. Just a last question, on development the styles is fine. But on production i still have a little FOUC. I did change the code accordingly to your indication (https://elegant-archimedes-313894.netlify.app/ , https://github.com/jocelinqueau/portfolio2021final). It is because of my bundle size ? do i need to do some optimization like lazy loading and minified css ? or it should do that ? |
When I follow your link, it doesn't look like FOUC, it throws still bugs in the terminal. FOUC would be only a short time before styles apply. Your site stays white/broken. Maybe use ESLint and Prettier to check all your code for errors. |
OK, it works (when I disable adblocking by Brave). Maybe something to look into. Maybe you have some dependency on some ad tracking or script that throws an error when it’s blocked. |
@kogakure i Will look into it, i weirdly have a cookie coming from a CDN for my images (cloudinary), and i asked them why for after googling about it with no real answer. But yeah it's weird others people have had reach my site without trouble |
Anyway, would there be somewhere to look for, as for why i still have a FOUC in production but not in development ? ( the code for gatsby-browser and gatsby-ssr is the same) |
layout 관련 css는 wrapPageElement에 넣어야 함 Ref) gatsbyjs/gatsby#24341
Description
Using the newest version of
gatsby-plugin-styled-components@3.3.2
withstyled-components@5.1.0
(any5.x
version) renders no CSS created withcreateGlobalStyles
to the<head>
. It works only with JavaScript enabled. I upgraded fromstyled-components@4.4.1
with the same plugin version and it stopped working.Steps to reproduce
Repository to reproducible demo. Two branches:
styled-components-4.4.1
(working)styled-components-5.1.0
(not working)Checkout branches and run
yarn build && yarn serve
.More details
I’m using
wrapRootElement
to add theThemeProvider
,Normalize
and myGlobalStyles
.I’m adding some CSS inside the
createGlobalStyle
method and also additionally load two external CSS Stylesheets at the end. The only CSS appearing in the<head>
of the SSR html is the one from the two statically included files. All other styles disappear.Expected result
What should happen?
A
<style>
tag holding all styles of styled-components should be in the<head>
after SSR is completed:Actual result
Environment
The text was updated successfully, but these errors were encountered: