diff --git a/README.md b/README.md index 339a454b5..5bfbfc7c0 100644 --- a/README.md +++ b/README.md @@ -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:

-|**`storageKey`**|string|| save current state to local storage. +|**`storageKey`**|string|| save current state to local storage(Only browser). ## Customize Columns 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; + } +};