Skip to content

Commit

Permalink
Merge pull request #1870 from gregnb/fixbug/window_not_defined
Browse files Browse the repository at this point in the history
fix : Changed to work only in browser(storageKey)
  • Loading branch information
wdh2100 committed Feb 20, 2022
2 parents 57e18e0 + ee56bf7 commit 9209ad3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -247,7 +247,7 @@ The component accepts the following props:
|**`tableBodyMaxHeight`**|string||CSS string for the height of the table (ex: '500px', '100%', 'auto').
|**`textLabels`**|object||User provided labels to localize text.
|**`viewColumns`**|boolean or string|true|Show/hide viewColumns icon from toolbar. Possible values:<p><ul><li>true: Button is visiable and clickable.</li><li>false: Button is not visible.</li><li>disabled: Button is visible, but not clickable.</li></ul></p>
|**`storageKey`**|string|| save current state to local storage.
|**`storageKey`**|string|| save current state to local storage(Only browser).

## Customize Columns

Expand Down
11 changes: 10 additions & 1 deletion 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;
}
};

0 comments on commit 9209ad3

Please sign in to comment.