Skip to content

fix: incorrect persistence useDarkMode #679

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tihonove
Copy link

@tihonove tihonove commented Feb 14, 2025

Fix useDarkMode persistence

This PR fixes #512. This pull request addresses the issue with the useDarkMode hook in what I believe is the best way: without modifying other hooks or adding overhead, unlike other PRs that attempt to fix this bug.

Changes:

  1. If there is no value in localStorage, it will not appear if the OS switches to dark mode.
  2. The absence of a value in localStorage means it will correspond to the OS setting or the defaultValue.
  3. Other hooks are used naturally without any modifications.

This fix ensures that the useDarkMode hook persistence correctly and efficiently.

Copy link

changeset-bot bot commented Feb 14, 2025

🦋 Changeset detected

Latest commit: ccce8e8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
usehooks-ts Patch
www Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

useDarkMode resets
1 participant