Skip to content

Commit d4cefc7

Browse files
fix: reset the page in the change-filters action
1 parent 6486b30 commit d4cefc7

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
],
2727
"author": "Mutasim Al-Mualimi <mutasim.business2020@gmail.com>",
2828
"license": "MIT",
29+
"repository": {
30+
"type": "git",
31+
"url": "https://github.com/programmersEmperor/use-paginated-list-query"
32+
},
2933
"dependencies": {
3034
"debounce-promise": "^3.1.2"
3135
},

src/usePaginatedList.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ function reducer<T, F>(state: State<T, F>, action: Action<T, F>): State<T, F> {
9191
filters: {
9292
...state.filters,
9393
...action.filters,
94+
page: 1,
9495
},
9596
};
9697
case "fetch-error":
@@ -149,10 +150,6 @@ function usePaginatedList<T extends FetchMethod>(args: Props<T>) : PaginatedList
149150
} as State<FetchMethodResult<T>, FetchMethodFilter<T>>);
150151
const debouncedFetchMethod = debounce(args.fetchMethod, args.debounceTime ?? 500);
151152

152-
useEffect(() => {
153-
changePage(1);
154-
}, [state.filters]);
155-
156153
useEffect(() => {
157154
fetchData();
158155

0 commit comments

Comments
 (0)