modify persistance logic, to allow adding new settings in the future

This commit is contained in:
gempir 2020-11-07 12:46:39 +01:00
parent f3250de594
commit 9217d54e69

View file

@ -34,5 +34,10 @@ export function useLocalStorage<T>(key: string, initialValue: T): [T, (value: T)
}
};
return [storedValue, setValue];
let returnValue = storedValue;
if (typeof initialValue === "object") {
returnValue = { ...initialValue, storedValue };
}
return [returnValue, setValue];
}