Skip to content

Commit 6486b30

Browse files
fix: reset the page number when filters chanages
1 parent 6ccafc6 commit 6486b30

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/usePaginatedList.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ function usePaginatedList<T extends FetchMethod>(args: Props<T>) : PaginatedList
149149
} as State<FetchMethodResult<T>, FetchMethodFilter<T>>);
150150
const debouncedFetchMethod = debounce(args.fetchMethod, args.debounceTime ?? 500);
151151

152+
useEffect(() => {
153+
changePage(1);
154+
}, [state.filters]);
155+
152156
useEffect(() => {
153157
fetchData();
154158

@@ -158,7 +162,6 @@ function usePaginatedList<T extends FetchMethod>(args: Props<T>) : PaginatedList
158162
}, [state.page, state.filters, args.disabled]);
159163

160164

161-
162165
async function fetchData() {
163166
if (args.disabled) {
164167
return;

0 commit comments

Comments
 (0)