Comments (8)
Sweet, thanks! I wasn't able to reproduce the issue on the first render, but I was able to reproduce the issue when doing setTheme('system')
twice.
since the theme value (in state) is not changed (still "system"), the "handleMediaQuery" is not triggered
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)
from next-themes.
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 !
from next-themes.
I also see it on 0.0.13, and I can reproduce it by setTheme("system") again after the initial set
from next-themes.
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 system
+ media query not working in SSR???
from next-themes.
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
from next-themes.
Thank you both for reporting this! I just published v0.0.13-beta.3
which should fix both #33 and #34 – please test and let me know if there is still an issue.
from next-themes.
Updating to the latest beta seems to have fixed the issue! I'm curious, what was the source of this bug?
from next-themes.
You rock @pacocoursey 🚀 it's fixed!
from next-themes.
Related Issues (20)
- `resolvedTheme` does not resolve to `dark` | `light` but instead to `system` HOT 1
- Support for multiple attributes (more in depth theme management)
- Flash of no theme (zero-config ThemeProvider, Next 14, not Cloudflare) HOT 1
- setTheme does not update DOM (next 13) HOT 1
- How can I get a transition between dark and light mode HOT 3
- defaultTheme did't work in the latest Chrome for macOS HOT 7
- Next Themes Flash of White BG when using the basePath HOT 4
- Inconsistent theming when the page loads HOT 3
- light/dark mode by changing class names on html tag HOT 2
- There is a error while setting up ThemeProvider HOT 5
- How to disable syncing themes between tabs HOT 2
- Documentation out of date with Tailwind's new dark-mode API
- Should `resolvedTheme` obey `forcedTheme`? HOT 3
- Allow nested providers HOT 2
- Theme object is injected into the "data-theme" property. HOT 1
- useTheme doesn't work in monorepo ui library. HOT 1
- `TypeError: Cannot read properties of undefined (reading 'addListener')` using `vitest`/`@testing-library/react` HOT 1
- Support for changing both class and data-theme attribute simultaneously HOT 1
- Callback Version of `setTheme` Passes Itself HOT 1
- Possibility to share across sub-domains? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next-themes.