store current theme in local storage

This commit is contained in:
tmshv committed 2022-10-12 16:36:33 +06:00
1 parent cb91aa22be
commit 1ef5b8553e
1 file changed
+3 -3
+3 -3
View File
@@ -1,4 +1,4 @@
import { useState } from "react"
import { useLocalStorage } from "react-use"
import { ThemeContext } from "./ThemeContext"
import { ThemeType } from "./types"
@@ -7,10 +7,10 @@ export type ThemeProps = {
}
export const Theme: React.FC<ThemeProps> = ({ children }) => {
const [theme, setTheme] = useState<ThemeType>("default")
const [theme, setTheme] = useLocalStorage<ThemeType>("hudozka-theme", "default")
return (
<ThemeContext.Provider value={[theme, setTheme]}>
<ThemeContext.Provider value={[theme ?? "default", setTheme]}>
{children}
</ThemeContext.Provider>
)