Skip to content

Commit 74e55a3

Browse files
committed
fix: fix sort state not unsetting when clicked 3 times
1 parent 6f95169 commit 74e55a3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/ui/DataTable/Hooks/useReactTableSortState.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ export default function useReactTableSortState(
3232

3333
const updateSortByFn = useCallback(
3434
(newSortBy: Updater<SortingState>) => {
35-
const sort = typeof newSortBy === "function" ? newSortBy([]) : newSortBy;
35+
const sort =
36+
typeof newSortBy === "function"
37+
? newSortBy([...tableSortByState])
38+
: newSortBy;
39+
console.log(sort);
3640
if (sort.length === 0) {
3741
searchParams.delete(sortByKey);
3842
searchParams.delete(sortOrderKey);
@@ -42,7 +46,7 @@ export default function useReactTableSortState(
4246
}
4347
setSearchParams(searchParams);
4448
},
45-
[searchParams, setSearchParams, sortByKey, sortOrderKey]
49+
[searchParams, setSearchParams, sortByKey, sortOrderKey, tableSortByState]
4650
);
4751

4852
return [tableSortByState, updateSortByFn];

0 commit comments

Comments
 (0)