-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Feature/fix unused moon and hydration error in theme toggle #649
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
base: main
Are you sure you want to change the base?
Feature/fix unused moon and hydration error in theme toggle #649
Conversation
👷 Deploy request for appcut pending review.Visit the deploys page to approve it
|
|
@srijanravisankar is attempting to deploy a commit to the OpenCut OSS Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughIntegrates a ThemeToggle component into the Projects page and fixes a bug in ThemeToggle where it always displayed the Sun icon and triggered hydration errors. The fix adds a client-side mounting guard and implements conditional icon rendering based on the current theme. Changes
Sequence DiagramsequenceDiagram
participant Client
participant Server
participant Theme as Theme Component
rect rgb(200, 220, 240)
Note over Client,Server: Before: Hydration Mismatch
Server->>Theme: Render (theme undefined)
Server->>Client: Send HTML (e.g., Sun icon)
Client->>Theme: Hydrate (theme determined client-side)
Client->>Client: Theme value differs from server output ✗
end
rect rgb(220, 240, 200)
Note over Client,Server: After: Hydration-Safe
Server->>Theme: Render nothing (mounted = false)
Server->>Client: Send empty placeholder
Client->>Theme: useEffect mounts component
Client->>Client: useTheme() hook initialized
alt theme is dark
Client->>Theme: Render Moon icon
else theme is light
Client->>Theme: Render Sun icon
end
Client->>Client: Server and client match ✓
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (5)**/*.{jsx,tsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{js,jsx,ts,tsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{tsx,jsx}📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
Files:
**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
Files:
🧠 Learnings (2)📚 Learning: 2025-08-09T09:03:49.797ZApplied to files:
📚 Learning: 2025-08-09T09:03:49.797ZApplied to files:
🧬 Code graph analysis (2)apps/web/src/app/projects/page.tsx (1)
apps/web/src/components/theme-toggle.tsx (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Description
This pull request fixes the unused Moon icon and resolves the hydration mismatch error in the ThemeToggle component.
The toggle now correctly switches between the Sun (dark → light) and Moon (light → dark) icons based on the current theme without any errors.
Fixes #648
Type of change
How Has This Been Tested?
Test Configuration:
Screenshots (if applicable)
Before:
Fix:
Checklist:
Additional context
Test:
opencut-moon-toggle-hydration-error-fix-testing.mp4
Summary by CodeRabbit
New Features
Bug Fixes
Accessibility