fix(use-theme): remove redundant applyTheme from toggleTheme

toggleTheme was calling applyTheme() inside the state updater AND
the useEffect was also applying on state change — double DOM write.
Now toggleTheme relies solely on the useEffect, matching setTheme
behavior.
This commit is contained in:
saravanakumardb1 2026-03-29 12:52:19 -07:00
parent 2688f7e3ca
commit bb86bf220e

View File

@ -80,10 +80,9 @@ export function useTheme(options?: UseThemeOptions): UseThemeReturn {
if (typeof window !== 'undefined') { if (typeof window !== 'undefined') {
window.localStorage.setItem(storageKey, next); window.localStorage.setItem(storageKey, next);
} }
applyTheme(next, attribute);
return next; return next;
}); });
}, [storageKey, attribute]); }, [storageKey]);
return { theme, setTheme, toggleTheme }; return { theme, setTheme, toggleTheme };
} }