fix: correct localstorage fallback

This commit is contained in:
2018-09-13 15:48:06 -07:00
parent 5bdd35b74b
commit d5b0cd0730

View File

@@ -1,14 +1,15 @@
/* eslint-env browser */ /* eslint-env browser */
const storage = (() => { const storage = (() => {
// return localstorage in the browser env try {
if (this && this.localStorage) return this.localStorage; return window.localStorage;
} catch (err) {
// return a mock localstorage in the server env // return a mock localstorage in the server env
return { return {
getItem: () => null, getItem: () => null,
setItem: () => null, setItem: () => null,
}; };
}
})(); })();
export default { export default {