From e0b63a0c5373921d20b23d0f13daa8b419872790 Mon Sep 17 00:00:00 2001 From: Narcha <42248344+Narcha@users.noreply.github.com> Date: Sun, 6 Nov 2022 08:07:43 +0100 Subject: [PATCH] [@mantine/hooks] use-local-storage: Fix incorrect value returned if `defaultValue` is not specified (#2872) --- src/mantine-hooks/src/use-local-storage/create-storage.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mantine-hooks/src/use-local-storage/create-storage.ts b/src/mantine-hooks/src/use-local-storage/create-storage.ts index 499e0c1987e..e674756f308 100644 --- a/src/mantine-hooks/src/use-local-storage/create-storage.ts +++ b/src/mantine-hooks/src/use-local-storage/create-storage.ts @@ -54,12 +54,12 @@ export function createStorage(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] );