diff --git a/packages/paste-website/src/hooks/useDarkMode.tsx b/packages/paste-website/src/hooks/useDarkMode.tsx index ef8b735f2f..02b7bd725e 100644 --- a/packages/paste-website/src/hooks/useDarkMode.tsx +++ b/packages/paste-website/src/hooks/useDarkMode.tsx @@ -13,7 +13,7 @@ const ValidThemes = { type ValidThemeName = ValueOf; const isValidTheme = (themeName: ValidThemeName): boolean => { - return themeName === ValidThemes.DEFAULT || themeName === ValidThemes.DARK; + return Object.values(ValidThemes).includes(themeName); }; export const useDarkMode = (): UseDarkModeReturn => { @@ -36,7 +36,7 @@ export const useDarkMode = (): UseDarkModeReturn => { React.useEffect(() => { const localTheme = SimpleStorage.get("theme") as ValidThemeName; - if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches && !localTheme) { + if (window.matchMedia?.("(prefers-color-scheme: dark)").matches && !localTheme) { setMode(ValidThemes.DARK); } else if (localTheme && isValidTheme(localTheme)) { setTheme(localTheme); diff --git a/packages/paste-website/src/pages/_app.tsx b/packages/paste-website/src/pages/_app.tsx index 3a8dc61473..588491a509 100644 --- a/packages/paste-website/src/pages/_app.tsx +++ b/packages/paste-website/src/pages/_app.tsx @@ -116,12 +116,18 @@ const App = ({ Component, pageProps }: AppProps): React.ReactElement => { disableAnimations={inCypress()} cacheProviderProps={{ key: "next" }} > - - - - {cookiesAccepted === null && } - - + {componentMounted ? ( + + + + {cookiesAccepted === null && ( + + )} + + + ) : ( + <> + )} );