modify persistance logic, to allow adding new settings in the future
This commit is contained in:
parent
f3250de594
commit
9217d54e69
1 changed files with 6 additions and 1 deletions
|
@ -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];
|
||||
}
|
Loading…
Add table
Reference in a new issue