In the underlying code, pages in the getNextPageParam method in infiniteQueryBehavior is undefined.
Describe the bug
We call the useInfiniteQuery function in @tanstack/react-query": "5.13.4":
const { refetch, data, isLoading, isFetching, isFetchingNextPage, fetchNextPage, hasNextPage, isSuccess, isFetched, error, isError, } = useInfiniteQuery({ queryKey: cacheKey, queryFn: async ({ pageParam }) => { const params = { [nextPageParam]: pageParam || nextPageDefault, limit: 50, reactions: isSubscription ? {} : { counts: true, own: true }, ...(ranking && { ranking }), }
let result
switch (feedGroup) {
case 'timeline':
result = await get({
path: '',
params,
})
break
case 'trending':
result = await get({
path: '',
params,
})
break
case 'subscription':
if (!userId) return
result = await get({
path: `/`,
params,
})
break
case 'exclusive':
result = await get({
path: '/',
params,
})
break
default:
result = await doFeedRequest<IActivityItem>(
client,
feedGroup,
feedId,
params
)
break
}
let data = result?.results || []
data = data.filter(
(activity) => activity.object && typeof activity.object === 'object'
)
if (appConfig.disableRecommendations) {
data = removeRecommendations(data)
}
cacheActivitiesReactions(data)
return {
data,
next: result?.next ? parse(result?.next)?.[nextPageParam] : undefined,
}
},
enabled: !isOnline || (!!client && enabled),
getNextPageParam: (lastPage) => lastPage?.next,
initialPageParam: '',
})
Will appear:
Your minimal, reproducible example
NO
Steps to reproduce
Expected behavior
no errors
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
Chrome Version 124.0.6367.62 (Official Build) (arm64)
Tanstack Query adapter
None
TanStack Query version
@tanstack/react-query": "5.13.4"
TypeScript version
"typescript": "5.2.2",
Additional context
No response
Thank you for filing this issue, but we need more information before looking into this.
Specifically, a minimal, standalone, runnable reproduction is needed - preferably with codesandbox or stackblitz. If your issue is TypeScript related, prefer a TypeScript playground.
We'll close this issue for now, but we'll certainly re-open it if there is a proper reproduction.