useUtils vs useQueryClient
I'm trying to use the
useUtils
hook but I'm unsure if I'm doing it correctly? It doesn't seem to work but using useQueryClient
does. Here is some code:
Am I doing something wrong?Solution:Jump to solution
Make sure you only have 1 of each QueryClient and trpcClient client in your react tree, kind of sounds like useUtils is getting hooked up to the wrong client
4 Replies
Why do you use refetch and not invalidate?
I was actually trying to use invalidate first. Has the same results with both - useQueryClient works but useUtils did nothing
I also tried on a query that has no input, same result
Solution
Make sure you only have 1 of each QueryClient and trpcClient client in your react tree, kind of sounds like useUtils is getting hooked up to the wrong client
Ahhhhhhh - thanks!! I didn't realize I had that issue... that must have been what's causing all kinds of other cache weirdness I was having issues with. Fixed!