fix: correct localstorage fallback
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
/* eslint-env browser */
|
||||
|
||||
const storage = (() => {
|
||||
// return localstorage in the browser env
|
||||
if (this && this.localStorage) return this.localStorage;
|
||||
|
||||
// return a mock localstorage in the server env
|
||||
return {
|
||||
getItem: () => null,
|
||||
setItem: () => null,
|
||||
};
|
||||
try {
|
||||
return window.localStorage;
|
||||
} catch (err) {
|
||||
// return a mock localstorage in the server env
|
||||
return {
|
||||
getItem: () => null,
|
||||
setItem: () => null,
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
||||
export default {
|
||||
|
||||
Reference in New Issue
Block a user