diff --git a/src/localStorage/load.js b/src/localStorage/load.js index 2d55e6843..17d82ff44 100644 --- a/src/localStorage/load.js +++ b/src/localStorage/load.js @@ -1 +1,10 @@ -export const load = storageKey => JSON.parse(window.localStorage.getItem(storageKey)); +const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined'; + +export const load = storageKey => { + if (isBrowser) { + return JSON.parse(window.localStorage.getItem(storageKey)); + } else if (storageKey !== undefined) { + console.warn('storageKey support only on browser'); + return undefined; + } +};