How to refetch query after mutation?
I now this is very basic task but seriously i don't know how to do it.
5 Replies
Pass a callback to onSuccess in the mutation hook, inside of that you just run query.refetch() or you invalidate it which you can see how to on docs
it works now, thanks
Does refetch do basically the same as invalidate?
If i have a direct access to useQuery is it better to use refetch?
Or there is no differnce
Refetch will force a loading state which is a way different UX. Invalidate does a background refetch
good to know