mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-25 23:17:06 +02:00
fix(v2): set stored theme only if it exists (#2113)
This commit is contained in:
parent
ba7c38cf0f
commit
bbc1d2cd51
1 changed files with 4 additions and 1 deletions
|
@ -14,7 +14,10 @@ const useTheme = () => {
|
||||||
);
|
);
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
try {
|
try {
|
||||||
setTheme(localStorage.getItem('theme'));
|
const localStorageTheme = localStorage.getItem('theme');
|
||||||
|
if (localStorageTheme !== null) {
|
||||||
|
setTheme(localStorageTheme);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue