Why is my query refetching when using the same query key?
I have this setup
My
pagination
object contains a pageNumber
.
On my initial load this is 1
. If I then go to the next page this is 2
and we get a new ajax request as expected.
However what's throwing me off is that if I then go back to the previous page so the value is 1
again the data is immediately returned, but then it seems a background request is fired to refresh the data.
How can I stop that background request?2 Replies
multiple-amethyst•2y ago
set
staleTime
continuing-cyanOP•2y ago
Ah thanks @TkDodo 🔮
And that made me realise I was using the old version of react-query
Upgraded now and gcTime vs cacheTime makes way more sense 🙂