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
barry
barry3y ago
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
vilchy ✓
vilchy ✓OP3y ago
it works now, thanks
stanisław
stanisław3y ago
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
isaac_way
isaac_way3y ago
Refetch will force a loading state which is a way different UX. Invalidate does a background refetch
barry
barry3y ago
good to know

Did you find this page helpful?