useInfiniteQuery: initial pageParams is unknown until first fetch
I have two APIs that will fetch chat messages
api/chat/private/{roomId} - fetches latest bucket, for example if the latest bucket is ID 41, it will, fetch ID 41 without specifying bucketId
api/chat/private/{roomId}/{bucketId} - fetches the specified bucket ID
pageParams = bucketId
the problem i am facing is that the app does not know what is the initial bucketId to put into the pageParams for useInfiniteQuery, so i'm using such work around
because the first API response will return the bucketId, i want to link this pageParam = bucketId instead of null after the first API is called, is there anyway to do it?
i'm trying to replace pageParams null value with pages[0].bucketId

2 Replies
ratty-blush•3y ago
setQueryData can update the pageParam
foreign-sapphireOP•3y ago
which event should I use to update?
actually is it important to update this pageParams? what does it actually do?