setQueryData + refetch vs fetchQuery
I'm reviewing a PR that has setQueryData + refetch (page uses useInfiniteQuery)
Wondering if its best practice to just use
useInfiniteQuery
with the new params or fetchInfiniteQuery
?10 Replies
vicious-gold•16mo ago
what are you trying to achieve ?
like-goldOP•16mo ago
its a refetch button on an app (webview) that performs a refetch. My understanding is we should just change the params to useInfiniteQuery or use fetchInfiniteQuery. This PR has setQueryData which is updating the pageParams with a date of now. The api returns a list based on a date (now)
vicious-gold•16mo ago
refetch is meant for refetch with the same params
like-goldOP•16mo ago
but what about in the instance above where a setQueryData and refetch is happning on a button click
vicious-gold•16mo ago
if it works it works. I've never done that
like-goldOP•16mo ago
cool.Can you clarify if running the query again will do the same thing? Is there any advantage to using setQuery data?
vicious-gold•16mo ago
It won't have the right pageParam, I guess that's why you're doing it
like-goldOP•16mo ago
what i mean is change those params. So change those pageParams and it will perform a query again. Seems a better way of doing this than setQuery + refetch?
vicious-gold•16mo ago
how would you change the pageParam ?
like-goldOP•16mo ago
ah yes of course. 🤦♂️ its not state
its passed in