Skip to content

Commit

Permalink
fix : Changed to work only in browser(storageKey)
Browse files Browse the repository at this point in the history
- for nextJS
  • Loading branch information
wdh2100 committed Feb 20, 2022
1 parent 57e18e0 commit e2098fc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/localStorage/load.js
Original file line number Diff line number Diff line change
@@ -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;
}
};

0 comments on commit e2098fc

Please sign in to comment.