From 3eb681c6bd18b835ec80057b368704d35ab81f37 Mon Sep 17 00:00:00 2001 From: Nandani Hada Date: Sat, 13 Dec 2025 20:33:40 +0530 Subject: [PATCH] Fix theme toggle icon mismatch after page reload - Fixed hydration issue where toggle showed wrong icon after reload - Component now waits for resolvedTheme to be available before rendering - Prevents flash of incorrect icon during next-themes initialization - Resolves #5 --- components/toggle-theme.tsx | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/components/toggle-theme.tsx b/components/toggle-theme.tsx index 55864df..491aeeb 100644 --- a/components/toggle-theme.tsx +++ b/components/toggle-theme.tsx @@ -29,7 +29,8 @@ export function ModeToggle() { // Use resolvedTheme to get the actual theme value (light/dark), not 'system' const currentTheme = resolvedTheme || theme - if (!mounted) { + // Don't render the interactive toggle until both mounted and theme is resolved + if (!mounted || !resolvedTheme) { return (
@@ -62,25 +63,22 @@ export function ModeToggle() { >