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 */
const storage = (() => {
// return localstorage in the browser env
if (this && this.localStorage) return this.localStorage;
try {
return window.localStorage;
} catch (err) {
// return a mock localstorage in the server env
return {
getItem: () => null,
setItem: () => null,
};
}
})();
export default {