Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix : Changed to work only in browser(storageKey) #1870

Merged
merged 2 commits into from Feb 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;
}
};