We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2ebe500 commit 2912787Copy full SHA for 2912787
src/localStorage/load.js
@@ -1 +1,10 @@
1
-export const load = storageKey => JSON.parse(window.localStorage.getItem(storageKey));
+const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
2
+
3
+export const load = storageKey => {
4
+ if (isBrowser) {
5
+ return JSON.parse(window.localStorage.getItem(storageKey));
6
+ } else if (storageKey !== undefined) {
7
+ console.warn('storageKey support only on browser');
8
+ return undefined;
9
+ }
10
+};
0 commit comments