fix(react): wrap loader in styledscope for consistent styling#174
Merged
chakrihacker merged 6 commits intomainfrom Mar 24, 2026
Merged
fix(react): wrap loader in styledscope for consistent styling#174chakrihacker merged 6 commits intomainfrom
chakrihacker merged 6 commits intomainfrom
Conversation
rax7389
reviewed
Mar 17, 2026
Contributor
rax7389
left a comment
There was a problem hiding this comment.
Unit test Checks are failing in also the PR doesn't describe before and after fix
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #174 +/- ##
========================================
Coverage 88.64% 88.65%
========================================
Files 154 154
Lines 13134 13140 +6
Branches 1716 1406 -310
========================================
+ Hits 11643 11649 +6
Misses 1491 1491 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
rax7389
reviewed
Mar 18, 2026
rax7389
reviewed
Mar 24, 2026
rax7389
reviewed
Mar 24, 2026
rax7389
approved these changes
Mar 24, 2026
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.
Problem
In Next.js with SSR, the server always rendered components with the default light theme, while the client-side React hydration would immediately switch to dark mode based on OS preference (prefers-color-scheme). This caused a hydration mismatch and a visible flash of incorrectly themed content on page load.
The root cause: the server has no access to window.matchMedia, so it cannot know the user's preferred color scheme at render time.
Solution
A cookie-based approach is used to bridge the server/client theme preference gap. The user's preferred theme is persisted to a theme-mode cookie, which the server can read on the next request to pre-render with the correct theme, eliminating the mismatch.
Before
After
Checklist