Fix local storage not handling null-values correctly

This commit is contained in:
Blue (Lukas Rieger) 2021-06-23 16:56:00 +02:00
parent ed67de14fe
commit df3676c5c9
No known key found for this signature in database
GPG Key ID: 904C4995F9E1F800

View File

@ -13,6 +13,10 @@ export const setLocalStorage = (key, value) => {
export const getLocalStorage = key => {
const value = localStorage.getItem(key);
// return undefined for not defined values
// because "null" might be ambiguous if there is actually "null" stored for that key
if (value == null) return undefined;
try {
return JSON.parse(value);
} catch(e) {