fix bug: inconsistant naming for localstorage key for theme provider
This commit is contained in:
@@ -21,12 +21,16 @@ const ThemeProviderContext = createContext<ThemeProviderState>({
|
||||
export function ThemeProvider({
|
||||
children,
|
||||
defaultTheme = "system",
|
||||
storageKey = "vite-ui-theme",
|
||||
storageKey = "theme",
|
||||
...props
|
||||
}: ThemeProviderProps) {
|
||||
const [theme, setTheme] = useState<Theme>(
|
||||
() => (localStorage.getItem(storageKey) as Theme) || defaultTheme
|
||||
)
|
||||
const [theme, setTheme] = useState<Theme>(() => {
|
||||
const stored = localStorage.getItem(storageKey)
|
||||
if (stored === "dark" || stored === "light" || stored === "system") {
|
||||
return stored
|
||||
}
|
||||
return defaultTheme
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
const root = window.document.documentElement
|
||||
|
||||
Reference in New Issue
Block a user