Git Product home page Git Product logo

Comments (8)

pacocoursey avatar pacocoursey commented on May 20, 2024 2

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: 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.

thien-do avatar thien-do commented on May 20, 2024

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.

thien-do avatar thien-do commented on May 20, 2024

I also see it on 0.0.13, and I can reproduce it by setTheme("system") again after the initial set

from next-themes.

jonahsnider avatar jonahsnider commented on May 20, 2024

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.

thien-do avatar thien-do commented on May 20, 2024

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.

pacocoursey avatar pacocoursey commented on May 20, 2024

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.

jonahsnider avatar jonahsnider commented on May 20, 2024

Updating to the latest beta seems to have fixed the issue! I'm curious, what was the source of this bug?

from next-themes.

thien-do avatar thien-do commented on May 20, 2024

You rock @pacocoursey 🚀 it's fixed!

from next-themes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.