Skip to content

Commit

Permalink
🐛 fixes #94
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Russo committed Jul 8, 2020
1 parent 1531a4b commit e5c9319
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -537,3 +537,8 @@ online

- useResizeObserver hook & documentation

## [0.27.1] - 2020-07-08

### Fixed

- useStorage throws an error on server side rendering as the window object is not defined yet
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "beautiful-react-hooks",
"version": "0.27.0",
"version": "0.27.1",
"description": "A collection of beautiful (and hopefully useful) React hooks to speed-up your components and hooks development",
"main": "dist/index.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/useStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import isDevelopment from './utils/isDevelopment';
*/
const useStorage = (type) => {
const storageName = `${type}Storage`;
const storage = window[storageName];

if (isClient && !isAPISupported(storageName)) {
// eslint-disable-next-line no-console
Expand All @@ -28,6 +27,7 @@ const useStorage = (type) => {
return [JSON.stringify(defaultValue), () => undefined];
}

const storage = window[storageName];
const [value, setValue] = useState(
safelyParseJson(storage.getItem(storageKey) || JSON.stringify(defaultValue)),
);
Expand Down

0 comments on commit e5c9319

Please sign in to comment.