question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

resolvedTheme can be `system`

See original GitHub issue

I have noticed in testing that useTheme().resolvedTheme can be system. 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?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
pacocourseycommented, Mar 17, 2021

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.

@thien-do explained it in #34

since the theme value (in state) is not changed (still “system”), the “handleMediaQuery” is not triggered

I updated the logic in this commit: https://github.com/pacocoursey/next-themes/pull/30/commits/8ab93d96b771cd4a523688d2cc6abce2386dada3

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)

0reactions
thien-docommented, Mar 18, 2021

You rock @pacocoursey 🚀 it’s fixed!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cristi on Twitter: "@raunofreiberg If you're using next-themes from ...
, make the setTheme(resolvedTheme === 'dark' ? 'light' : 'dark') - not on 'theme', because if the default system is dark it will...
Read more >
[RESOLVED] Theme-Editor Error - Page 2 - General - Forums
Something is apparently amiss with your system - be it an update or something else installed along the way which may require a...
Read more >
Step-By-Step Guide to Adding Dark Mode and Multiple ...
With themes, users can easily switch between light and dark modes, or change the color scheme of the app, depending on their preference....
Read more >
Architect a Theming System — Component Themes with Sass
As you can see from the sample above, all of our colors are consumed from the resolved theme. We can now customize the...
Read more >
[resolved] Theme: Clear, Text Formatting Of Description - Piwigo
Can someone help me with this, please? I am so far only a beginner with CSS Thanks for any support. Piwigo 11.2.0. Operating...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found