OpenCut-app / OpenCut-app/OpenCut
[BUG] ThemeToggle always shows Sun icon and causes hydration error during SSR
Open
Nobody has claimed this yet.
bug
- Dominant language
- TypeScript
- Stars
- 89.8k
- Forks
- 8.9k
- PR merge metrics
- No merged PRs in 30d
Description
Platform
Windows 11
Browser
Brave
Current Behavior
- Bug 1: The ThemeToggle component always displays the Sun icon, even when the app is in dark mode, so users never see the Moon icon.
- Bug 2: Additionally, it triggers a hydration error in the console because useTheme() from next-themes returns different values on the server and client.
Expected Behavior
- Fix 1: The component should correctly display the Sun icon in dark mode and the Moon icon in light mode.
- Fix 2: The theme toggle should not cause any hydration errors when switching between modes or when rendering on the client.
Recurrence Probability
Always
Steps To Reproduce
- Pull and run the latest main branch.
- Navigate to a page that includes the ThemeToggle component.
- Switch between dark and light themes.
- Observe:
- The icon never changes (always Sun).
- The browser console logs a hydration mismatch error.
Anything else?
In light theme:
In dark theme:
Hydration Error:
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the ThemeToggle component and inspect its useTheme() usage and server/client rendering path. Reproduce the issue on a page that includes ThemeToggle, then verify that the icon reflects the active theme and the console reports no hydration mismatch when switching modes. The issue names no file or test, so locate the component and relevant test entry point first.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- next.js, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100