Skip to content

Commit

Permalink
Initialize totalCount with Infinity
Browse files Browse the repository at this point in the history
  • Loading branch information
NikhilA8606 committed Dec 11, 2024
1 parent d3b8102 commit f9249dc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Utils/request/useInfiniteQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function useInfiniteQuery<TItem>(
options?: InfiniteQueryOptions<TItem>,
) {
const [items, setItems] = useState<TItem[]>([]);
const [totalCount, setTotalCount] = useState<number>();
const [totalCount, setTotalCount] = useState<number>(Infinity);
const [offset, setOffset] = useState(0);

const { refetch, loading, ...queryResponse } = useQuery(route, {
Expand Down Expand Up @@ -55,7 +55,7 @@ export function useInfiniteQuery<TItem>(
fetchNextPage,
refetch,
totalCount,
hasMore: items.length < (totalCount ?? 0),
hasMore: totalCount ? items.length < totalCount : true,
...queryResponse,
};
}

0 comments on commit f9249dc

Please sign in to comment.