Skip to content

Commit

Permalink
feat: paging was applied to the filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
Franqsanz committed Jul 29, 2024
1 parent e21987d commit 7deb7c2
Show file tree
Hide file tree
Showing 5 changed files with 276 additions and 195 deletions.
2 changes: 1 addition & 1 deletion src/components/AllBooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function AllBooks() {
useBooksPaginate();
let fetchingNextPageUI;

useScrollRestoration(isPending); // Restablecer la posición del scroll al volver de la vista del libro
useScrollRestoration(isPending); // Restablece la posición del scroll al volver de la vista del libro

useEffect(() => {
let isMounted = true;
Expand Down
17 changes: 15 additions & 2 deletions src/hooks/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,22 @@ function useBooksPaginate() {
}

function useFilter(query: string | undefined, param: string | undefined) {
return useSuspenseQuery({
// return useSuspenseQuery({
// queryKey: [keys.filter, query, param],
// queryFn: () => getBooksFilter(query, param, page),
// gcTime: 3000,
// retry: 1,
// });

return useInfiniteQuery({
queryKey: [keys.filter, query, param],
queryFn: () => getBooksFilter(query, param),
queryFn: ({ pageParam }) => getBooksFilter(query, param, pageParam),
initialPageParam: 0,
getNextPageParam: (lastPage) => {
if (lastPage.info.nextPage === null) return;

return lastPage.info.nextPage;
},
gcTime: 3000,
retry: 1,
});
Expand Down
Loading

0 comments on commit 7deb7c2

Please sign in to comment.