From 3ccbb40d69a9595ebadf6996364cfdfa0072867c Mon Sep 17 00:00:00 2001 From: aidanCQ Date: Fri, 29 Dec 2023 16:45:49 +0000 Subject: [PATCH] fix(): Immediately load theme if window exists. --- src/molecules/theme-selector.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/molecules/theme-selector.tsx b/src/molecules/theme-selector.tsx index 211af26..142325a 100644 --- a/src/molecules/theme-selector.tsx +++ b/src/molecules/theme-selector.tsx @@ -7,7 +7,7 @@ import { theme as _theme } from "src/utils"; type Mode = ReturnType['mode'] export const useTheme = () => { - const [theme, _setTheme] = React.useState>({mode: "dark", isDark: true}); + const [theme, _setTheme] = React.useState>(typeof window !== "undefined" ? _theme.get() : {mode: "dark", isDark: true}); React.useEffect(() => { _theme.subscribe(() => { _setTheme(_theme.get());