Infinite query fetches next page on every rerender. Why?
I toggle a setting
showOwnOnly which triggers a rerender. On that rerender, I can see, that the infiniste query i am using fetches the next page.
The queryKey is stable (otherwise it probably would start at page 0 again).
Here is how I use the query:
useEvents is this:
Is this by design? How can I stop that from happening?1 Reply
fascinating-indigo•10mo ago
Hey there! It is hard to say exactly without seeing the
fetchSomething call but using in the queryFn you would be using it like:
Where you are passing in a pageParam which is used to paginated the calls. Can you confirm that this is the setup you have? Something else to check would be that this queryFn is async but you aren't awaiting the fetchSomething which may be causing some weird double firing, probably not, but worth checking.
I'd log out these pageParams and the lastPage and see if there is any flaw in the logic there. Next I'd make sure that the fetchNextPage is not double firing in the location you have that