OpenCut-app / OpenCut-app/OpenCut

[BUG] ThemeToggle always shows Sun icon and causes hydration error during SSR

Open
#648 1 comment 0 reactions 0 assignees View on GitHub

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
  1. Pull and run the latest main branch.
  2. Navigate to a page that includes the ThemeToggle component.
  3. Switch between dark and light themes.
  4. Observe:
    • The icon never changes (always Sun).
    • The browser console logs a hydration mismatch error.
Anything else?

In light theme:
Image

In dark theme:
Image

Hydration Error:
Image

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.