Hydartion boundary (version 5) Next Js
When using hydration boundary with useInfiniteQuery , then useInfiniteQuery throwing error " Cannot read properties of undefined (reading 'length')
at getNextPageParam "
server component
<HydrationBoundary state={dehydratedState}>
<ArticlesContainer view={view} />
</HydrationBoundary>
client component
const { data, hasNextPage, fetchNextPage, isFetchingNextPage } =
useInfiniteQuery({
queryKey: ["posts"],
queryFn: async ({ pageParam = 1 }) => {
const data = (await getArticles({ pageParam })) as any;
return data;
},
getNextPageParam: (data) => {
if (data.nextPage) {
return data.nextPage;
}
return null;
},
initialPageParam: 1,
});
If something is wrong , please provide me example
1 Reply
fascinating-indigo•3y ago
This is fixed in v5