React query initial data

const { data } = useInfiniteQuery({
queryKey: ["releases"],
initialPageParam: initialNextId,
queryFn: async ({ pageParam }) => {
const releases = await getReleases({ limit: 2, cursor: pageParam });
return releases.data;
},
getNextPageParam: (lastPage) => lastPage?.nextId,
initialData: {
pages: {
releases: initialReleases,
nextId: initialNextId,
},
pageParams: [""],
},
});
const { data } = useInfiniteQuery({
queryKey: ["releases"],
initialPageParam: initialNextId,
queryFn: async ({ pageParam }) => {
const releases = await getReleases({ limit: 2, cursor: pageParam });
return releases.data;
},
getNextPageParam: (lastPage) => lastPage?.nextId,
initialData: {
pages: {
releases: initialReleases,
nextId: initialNextId,
},
pageParams: [""],
},
});
I'm getting an error that initial data type isn't correct
Solution:
```ts initialData: { pageParams: [undefined], pages: [{ releases: initialReleases, nextId: initialNextId }], },...
Jump to solution
1 Reply
Solution
iboughtbed
iboughtbed13mo ago
initialData: {
pageParams: [undefined],
pages: [{ releases: initialReleases, nextId: initialNextId }],
},
initialData: {
pageParams: [undefined],
pages: [{ releases: initialReleases, nextId: initialNextId }],
},
Want results from more Discord servers?
Add your server