issue #3: Fix: Resolve Hydration Error and Optimize theme-switch.tsx for Better Theme Handling #4
Open
sumanpaikdev wants to merge 3 commits into3p5ilon:mainfrom
Open
issue #3: Fix: Resolve Hydration Error and Optimize theme-switch.tsx for Better Theme Handling #4sumanpaikdev wants to merge 3 commits into3p5ilon:mainfrom
sumanpaikdev wants to merge 3 commits into3p5ilon:mainfrom
Conversation
UPDATED THEME-SWITCH.TSX ; BETTER OPTIMIJATION AND PREVENT HYDRATION ERROR.
IN THE UPDATED THEME-SWITCH.TSX WE ARE NOT USING THE PROPS
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Copied over the hydration error fix and works great for me. Please merge this! |
|
This is a great fix, thanks @sumanpaikdev. I noticed however when the user's system preference is set to dark theme the theme on site is accordingly dark but is stored as This of course brings back the Hydration error, but this can be fixed by wrapping |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request addresses two key issues:
1. Hydration Error:
2. Optimization of
theme-switch.tsx:lightordark) dynamically.localStorageand system theme changes.Changes Made
mountedstate to defer rendering until the theme state is fully initialized.toggleThemefunction for cleaner state management.window.matchMedia.Testing