-
Hey! I have this code that use const { data, isLoading, hasNextPage, fetchNextPage } = useInfiniteQuery({
// ^? { data: InfiniteData<unknown, unknown>, ... }
queryKey: ['get-data'],
initialPageParam: 1,
getNextPageParam: (lastPage, allPages) => {
// the type here will also be inferred as unknown
if (lastPage?.totalPage && lastPage.data.length < 50) return undefined;
return allPages.length;
},
queryFn: ({ pageParam }) => getData(),
}); and by using that order, the But if the order is "correct" const { data, isLoading, hasNextPage, fetchNextPage } = useInfiniteQuery({
// ^? { data: InfiniteData<TData, unknown>, ... }
queryKey: ['get-data'],
queryFn: ({ pageParam }) => getData(),
initialPageParam: 1,
getNextPageParam: (lastPage, allPages) => {
// ^? (lastPage: TData, allPages: TData[])
if (lastPage?.totalPage && lastPage.data.length < 50) return undefined;
return allPages.length;
},
}); So my question is, is this expected that the placement of the options have to be in specific order in order to correctly have the return type of |
Beta Was this translation helpful? Give feedback.
Answered by
TkDodo
Nov 20, 2024
Replies: 1 comment 1 reply
Answer selected by
bobkombat
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
see: