diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index e1157141..1455f495 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -32,7 +32,10 @@ function MainLayout() {
}
export default function App() {
- useDarkTheme();
+ const [,,componentMounted] = useDarkTheme();
+ if(!componentMounted) {
+ return
+ }
return (
diff --git a/frontend/src/hooks/index.ts b/frontend/src/hooks/index.ts
index dfb9cb46..b993f3da 100644
--- a/frontend/src/hooks/index.ts
+++ b/frontend/src/hooks/index.ts
@@ -82,6 +82,7 @@ export function useDarkTheme() {
};
const [isDarkTheme, setIsDarkTheme] = useState(getInitialTheme());
+ const [componentMounted, setComponentMounted] = useState(false);
useEffect(() => {
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
@@ -102,11 +103,12 @@ export function useDarkTheme() {
} else {
document.body?.classList.remove('dark');
}
+ setComponentMounted(true);
}, [isDarkTheme]);
const toggleTheme = () => {
setIsDarkTheme(!isDarkTheme);
};
- return [isDarkTheme, toggleTheme] as const;
+ return [isDarkTheme, toggleTheme, componentMounted] as const;
}