-
Notifications
You must be signed in to change notification settings - Fork 674
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
colors from outside of theme are not recomputed on initial render after Gatsby SSR #1602
Comments
Thanks for the issue and the reproduction @ehowey! |
useColorMode
not properly initializing in production site using v0.6 and Gatsby
This is definitely something I broke while fixing color modes flash — previously we always started with default color mode and you could see the colors (except background and text) blink, but in this case you need the flash. When the website SSRs, "mode" is Based on the quick fiddling I gave it today,
BTW You can set As a quick workaround, you could add the color to the theme, but I realize this is less than ideal. |
Thanks for looking into this. Just as an FYI - this shows up in development even with the |
@ehowey const SSRFix = colorMode === undefined ? undefined : 'light'
const trueColorMode = colorMode === SSRFix ? 'light' : 'dark' That way, it'll work both locally and with SSR. @hasparus Any way we can have the default color mode show up as |
The default should be Though, in the browser we read it from |
I'll do some more tests, and make more complete specs. But so far, when is set |
Just wondering where this stands on the priority list of fixes, or is it a bigger deal/longer term and I should implement the work around mentioned above? |
Not sure! We've fixed Fast Refresh support & #1672 should improve performance here, but if you'd like to take on fixing this, we'd love to review/get it released quickly. |
@ehowey we already have a PR fixing this, so testing, possible fixes and releasing shouldn't take more than a few days |
Thank-you! Sorry I didn't mean for you all to feel rushed. I really appreciate all of your work on Theme-UI! |
No worries :) Though, I'd advise to go with the workaround. |
Hey @ehowey, just FYI. This make take us some more time. |
Describe the bug
Minimal Repo: https://github.com/ehowey/color-mode-bug
Relevant code: https://github.com/ehowey/color-mode-bug/blob/main/src/pages/index.js
Live site: https://condescending-blackwell-39cd84.netlify.app/
Previously I could use code like the following to dynamically update images in dark mode, e.g. setting
invert(1)
to invert an image for dark mode. This code is still working fine in development mode but is breaking production mode. I have created a minimal repo and a deploy to Netlify to test this. You can see in the console log it is properly catching the mode as dark but for some reason the text and images are not updating their css based on the color mode.To test this make sure you are visiting the live site in incognito mode as it will correctly change the colors and image on the second load once the cache is set.
Expected behavior
Previously
isDark
could be used like a boolean flag in the CSS to toggle different colors based on the color mode.The text was updated successfully, but these errors were encountered: