From fd2f4aa4b28ea659e1b171eb393cf72a071b97db Mon Sep 17 00:00:00 2001 From: aanaya-deltacom <68325852+aanaya-deltacom@users.noreply.github.com> Date: Tue, 17 Aug 2021 09:09:02 +0200 Subject: [PATCH] fix: removeOnUndefined option using Angular Universal Check if storage is undefined before using removeItem --- projects/lib/src/lib/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/lib/src/lib/index.ts b/projects/lib/src/lib/index.ts index 508810d..3e730bb 100644 --- a/projects/lib/src/lib/index.ts +++ b/projects/lib/src/lib/index.ts @@ -212,7 +212,7 @@ export const syncStateUpdate = ( } catch (e) { console.warn('Unable to save state to localStorage:', e); } - } else if (typeof stateSlice === 'undefined' && removeOnUndefined) { + } else if (typeof stateSlice === 'undefined' && removeOnUndefined && storage !== undefined) { try { storage.removeItem(storageKeySerializer(key as string)); } catch (e) {