mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-25 15:07:17 +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(() => {
|
||||
try {
|
||||
setTheme(localStorage.getItem('theme'));
|
||||
const localStorageTheme = localStorage.getItem('theme');
|
||||
if (localStorageTheme !== null) {
|
||||
setTheme(localStorageTheme);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue