code quality improvement
This commit is contained in:
parent
2b10086cc6
commit
25e9c10e26
1 changed files with 6 additions and 5 deletions
|
@ -125,14 +125,15 @@ blockquote {
|
||||||
`
|
`
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [usingTheme, _setTheme] = useState(() => {
|
const [currentTheme, _setTheme] = useState(() => {
|
||||||
const savedTheme = storage.getItem("theme")
|
const savedTheme = storage.getItem("theme")
|
||||||
return savedTheme ? JSON.parse(savedTheme) : { mode: "dark" }
|
return savedTheme ? JSON.parse(savedTheme) : { mode: "dark" }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// save theme when theme is changed
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
storage.setItem("theme", JSON.stringify(usingTheme))
|
storage.setItem("theme", JSON.stringify(currentTheme))
|
||||||
}, [usingTheme])
|
}, [currentTheme])
|
||||||
|
|
||||||
const [isLoading, setLoading] = useState(true)
|
const [isLoading, setLoading] = useState(true)
|
||||||
|
|
||||||
|
@ -154,7 +155,7 @@ function App() {
|
||||||
<HelmetProvider>
|
<HelmetProvider>
|
||||||
<ThemeProvider
|
<ThemeProvider
|
||||||
theme={{
|
theme={{
|
||||||
...usingTheme,
|
...currentTheme,
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
setTheme: ({ setTheme, ...theme }) => _setTheme(theme), // make setTheme function available in other components
|
setTheme: ({ setTheme, ...theme }) => _setTheme(theme), // make setTheme function available in other components
|
||||||
}}
|
}}
|
||||||
|
@ -167,7 +168,7 @@ function App() {
|
||||||
<Spinner
|
<Spinner
|
||||||
size={200}
|
size={200}
|
||||||
color={
|
color={
|
||||||
usingTheme.mode == "light"
|
currentTheme.mode == "light"
|
||||||
? theming.light.color1
|
? theming.light.color1
|
||||||
: theming.dark.color1
|
: theming.dark.color1
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue