Skip to content

Commit

Permalink
fix: removeOnUndefined option using Angular Universal
Browse files Browse the repository at this point in the history
Check if storage is undefined before using removeItem
  • Loading branch information
aanaya-deltacom authored Aug 17, 2021
1 parent 241e7bf commit fd2f4aa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion projects/lib/src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit fd2f4aa

Please sign in to comment.