diff --git a/src/shared/ThemeContext/ThemeContext.tsx b/src/shared/ThemeContext/ThemeContext.tsx index 59e9222bc6..e0610accae 100644 --- a/src/shared/ThemeContext/ThemeContext.tsx +++ b/src/shared/ThemeContext/ThemeContext.tsx @@ -38,8 +38,13 @@ export const ThemeContextProvider: FC = ({ systemTheme = Theme.DARK } - const currentTheme = localStorage.getItem('theme') as Theme - const [theme, setTheme] = useState(currentTheme ?? systemTheme) + const storedTheme = localStorage.getItem('theme') + const currentTheme: Theme | null = Object.values(Theme).includes( + storedTheme as Theme + ) + ? (storedTheme as Theme) + : null + const [theme, setTheme] = useState(currentTheme || systemTheme) const initialRender = useRef(true) if (initialRender.current) {