fix mismatch

This commit is contained in:
Michael Freno
2025-12-31 01:52:13 -05:00
parent 81b7c6e322
commit ff681e6b3a
2 changed files with 28 additions and 7 deletions

View File

@@ -49,7 +49,13 @@ export const DarkModeProvider: ParentComponent = (props) => {
// Initialize with correct theme synchronously
const [isDark, setIsDark] = createSignal(getInitialTheme());
// Force update immediately on client to fix hydration mismatch
onMount(() => {
const actualTheme = getInitialTheme();
if (isDark() !== actualTheme) {
setIsDark(actualTheme);
}
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
// Listen for system theme changes