Repository navigation
Styled-Components initial render and refresh fail #52775
|
hi, i have the problem that my styles only load when i click the DarkmodeToggle button. On first load there is no style and on refresh of the page also not all styles load only when I use the button. my registry.tsx: my ConfigContext.tsx: my layout.tsx: my GlobalStyle.tsx: when loading for the first time or after a reload it looks like this: if I click it again for light mode: I've been trying for weeks now, haven't found anything in the nice and nextjs forum didn't give me any answers and no one replied to my post. I just do not understand what I am doing wrong. How do I make one of the styles exist on first load? I also have a reproduction of the whole thing here: hosted: https://reproduction-qw5w3tzgc-nyxb.vercel.app/?vercelToolbarCode=o-v6DTVoCiFJkBA |
Replies: 1 comment 11 replies
|
Uff I might be off here, but doesn't the ThemeProvider have to be inside a |



yeah, because you wait for the
useEffect, and that happens way after the DOM has painted.Check it out now :)
Since you said you spent many weeks on this, I've been trying to only go on incremental steps with a "fix". After all this is nothing to do with styled-components.