Skip to content
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

Double rendering on Gatsby Cloud #19

Open
leokolt opened this issue Oct 22, 2022 · 2 comments
Open

Double rendering on Gatsby Cloud #19

leokolt opened this issue Oct 22, 2022 · 2 comments

Comments

@leokolt
Copy link

leokolt commented Oct 22, 2022

Hi. My website, which is not yet ready to the end, runs on Gatsby Cloud. I had the same problem as many - I had to click on toggler several times to change the color theme immediately after loading the site. I added the code from this commit and the problem disappeared, but another problem appeared - now my site is rendered twice after loading. You can see it here. Is there any way to solve this problem?

Errors in the console are shown in the picture below. The error description is as follows:

Hydration failed because the initial UI does not match what was rendered on the server.
&
There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.

image

@fabianjost
Copy link

Did you find a solution to this? I am facing the exact same issue with the same errors in the production build.

@fabianjost
Copy link

FYI for everyone comming across this issue:
This seems to be related to the ThemeToggler component. I couldn't find out what the exact issue with it is. I fixed it by simply writing this component myself. In case you want to omit using this package after all, keep in mind that you need to set the theme in the gatsby-ssr.js file (e.g. by adding the 'dark' class to the body). Setting it in gatsby-browser.js is already too late and will cause the page to flicker/quickly change theme during initial page load.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants