Преглед на файлове

fix: limit theme mode value

GyDi преди 2 години
родител
ревизия
c1734a094c
променени са 1 файла, в които са добавени 6 реда и са изтрити 2 реда
  1. 6 2
      src/components/layout/use-custom-theme.ts

+ 6 - 2
src/components/layout/use-custom-theme.ts

@@ -16,8 +16,12 @@ export default function useCustomTheme() {
   const [mode, setMode] = useRecoilState(atomThemeMode);
 
   useEffect(() => {
-    if (theme_mode !== "system") {
-      setMode(theme_mode ?? "light");
+    const themeMode = ["light", "dark", "system"].includes(theme_mode!)
+      ? theme_mode!
+      : "light";
+
+    if (themeMode !== "system") {
+      setMode(themeMode);
       return;
     }