-
-
Notifications
You must be signed in to change notification settings - Fork 166
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
resolvedTheme can be system
#33
Comments
Yeah this is really weird.. I also see this behavior, but by reading the code it should not happen https://github.com/pacocoursey/next-themes/blob/master/index.tsx ! |
I also see it on 0.0.13, and I can reproduce it by setTheme("system") again after the initial set |
I think it also happened on the latest stable version (which is what prompted me to update to beta). Maybe it has to do with the default theme being |
Yeah the latest version doesn't change the resolving part so I think it likely is. Actually I cannot reproduce your exact issue (resolvedTheme returns "system") but I do see some related issue I noted at #34 it's when the "system" is being used for "data-theme". In my case, resolvedTheme is still correct (either "light" or "dark") but the data-theme is set incorrectly |
Updating to the latest beta seems to have fixed the issue! I'm curious, what was the source of this bug? |
Sweet, thanks! I wasn't able to reproduce the issue on the first render, but I was able to reproduce the issue when doing
I updated the logic in this commit: 8ab93d9 Basically when setting theme to system, it wasn't applying the resolved theme – that only happened by accident! This adds the check and actually makes it faster (previously there were two calls: one to update the DOM to system, then another to update the DOM to dark/light) |
You rock @pacocoursey 🚀 it's fixed! |
I have noticed in testing that
useTheme().resolvedTheme
can besystem
. I think it's only happening in the first render, but I haven't tried making a minimal reproduction.I am using next-themes@npm:0.0.13-beta.2 [
9e7cc
] (via npm:beta [9e7cc
]) and not passing any options to<ThemeProvider>
.Is this expected behavior?
The text was updated successfully, but these errors were encountered: