diff --git a/docs/stories/Intro.stories.tsx b/docs/stories/Intro.stories.tsx index 2be51dc..bcb1d3e 100644 --- a/docs/stories/Intro.stories.tsx +++ b/docs/stories/Intro.stories.tsx @@ -52,3 +52,9 @@ export const SortDisabledOne = { })), }, }; + +export const Persitance = { + args: { + persist: { storage: localStorage, id: 'tablePersitance' }, + }, +}; diff --git a/src/internalState/tableStateStorage.ts b/src/internalState/tableStateStorage.ts index 21b6f10..5ff5b96 100644 --- a/src/internalState/tableStateStorage.ts +++ b/src/internalState/tableStateStorage.ts @@ -189,21 +189,8 @@ export function useTableStateStorage(table: Store>) { return; } - const { storage } = persist; - const keys = - 'keys' in storage - ? await storage.keys() - : await Promise.all( - Array(storage.length) - .fill(0) - .map((_x, i) => storage.key(i)), - ); - - for (const key of keys) { - if (key !== null) { - await storage.removeItem(key); - } - } + const { storage, id } = persist; + await storage.removeItem(storageName(id)); q.clear(); });