Skip to content
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

[BUG] Vite's hot reload resets dark mode setting when using useDarkMode() #433

Closed
juliencrn opened this issue Jan 20, 2024 Discussed in #427 · 1 comment
Closed

[BUG] Vite's hot reload resets dark mode setting when using useDarkMode() #433

juliencrn opened this issue Jan 20, 2024 Discussed in #427 · 1 comment
Labels
bug Something isn't working

Comments

@juliencrn
Copy link
Owner

Discussed in #427

Originally posted by joonashak January 18, 2024
Recently discovered your useDarkMode() hook, and love it! I'm just running into an issue with Vite, where the dev server's hot reload/HMR resets the dark mode setting.

Repro steps:

  1. Have dark mode as browser preference. Dark mode is displayed correctly.
  2. Switch to light mode. Reload page to confirm that the preference is persisted.
  3. Save a file watched by Vite's dev server. Theme changes back to dark mode as the hot-reload happens in browser.

This is pretty frustrating when working on light mode's colors, etc. Is there a way to have the user preference persisted over hot-reloads? Thanks!

@juliencrn juliencrn added the bug Something isn't working label Jan 20, 2024
@juliencrn
Copy link
Owner Author

Hi @joonashak, using usehooks@2.13.0 looks good. I carefully reproduced the steps and the dark mode stayed on light.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant