Simplify "useStorage" hook

This commit is contained in:
schroda
2025-07-28 20:57:16 +02:00
parent 7eb3b0ac45
commit a38b2fce9d

View File

@@ -34,8 +34,7 @@ function useStorage<T>(
// Allow value to be a function so we have same API as useState
const valueToStore = (() => {
if (value instanceof Function) {
const previousValue =
jsonSaveParse(storage.getItem(key) ?? '') ?? storage.getItemParsed(key, initialState);
const previousValue = storage.getItemParsed(key, initialState);
return value(previousValue);
}