Skip to content

Commit 4937cba

Browse files
committed
fix: Default hasMoreResults to true while loading
The infinite scroll trigger was broken because hasMoreResults returned undefined (falsy) when SWR data hadn't loaded yet. This prevented the InfiniteScroll component from triggering the next fetch. Now hasMoreResults defaults to true while isFetchingClimbs is true (so infinite scroll works during SSR hydration), and false after loading completes with no data.
1 parent 0c88546 commit 4937cba

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/web/app/components/queue-control/hooks/use-queue-data-fetching.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ export const useQueueDataFetching = ({
6161
initialSize: searchParams.page ? searchParams.page + 1 : 1,
6262
});
6363

64-
const hasMoreResults = data && data[0] && size * PAGE_LIMIT < data[0].totalCount;
64+
// When data exists, calculate normally. Otherwise default to true while loading
65+
// (so infinite scroll works during SSR hydration), or false after loading completes with no data
66+
const hasMoreResults = data?.[0] ? size * PAGE_LIMIT < data[0].totalCount : isFetchingClimbs;
6567
const totalSearchResultCount = (data && data[0] && data[0].totalCount) || null;
6668

6769
const climbSearchResults = useMemo(

0 commit comments

Comments
 (0)