Skip to content

Commit

Permalink
[@mantine/hooks] use-local-storage: Fix incorrect value returned if `…
Browse files Browse the repository at this point in the history
…defaultValue` is not specified (#2872)
  • Loading branch information
Narcha committed Nov 6, 2022
1 parent a90a96f commit e0b63a0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mantine-hooks/src/use-local-storage/create-storage.ts
Expand Up @@ -54,12 +54,12 @@ export function createStorage<T>(type: StorageType, hookName: string) {
window[type] === null ||
skipStorage
) {
return (defaultValue ?? '') as T;
return defaultValue as T;
}

const storageValue = window[type].getItem(key);

return storageValue !== null ? deserialize(storageValue) : ((defaultValue ?? '') as T);
return storageValue !== null ? deserialize(storageValue) : (defaultValue as T);
},
[key, defaultValue]
);
Expand Down

0 comments on commit e0b63a0

Please sign in to comment.