Fix header theme hydration mismatch#83
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe Header component's theme toggle mechanism is refactored to rely on Tailwind's ChangesHeader Theme Toggle Refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Comment |
|
Actionable comments posted: 0 |
Summary
dark:classes.localStorage.theme = lightand asserts React #418 is not emitted.Root cause
The server rendered the header as dark because
windowis unavailable during SSR, but the client's first render readlocalStorage/prefers-color-schemeand could render the light header immediately. That changed the initial DOM and triggered React hydration error #418.Tests
npm run test:i18nnpm run test:unitnpm run buildnpm run test:e2e -- tests/theme-consistency.spec.tsnpm run test:e2e/en/addons/reson8/with stored light theme: 0 console errorsSummary by CodeRabbit
Refactor
Tests