QueryClient shows my cache is being updated during my mutation. However the component isn't updating
Like my title says, I did some stack refactoring that seemed to be unrelated to this but now my useQuery hook doesn't seem to be updating with the new value. Can anyone spot anything wrong with my pattern here?
My log on line 48 (picture 1) is showing my query is in fact being updated like I would expect, but I don't see the new data in my component (picture 2)


7 Replies
extended-yellow•9mo ago
Try
await queryClient.invalidateQueries(...)
Although, you're setting the query data for that same queryKey? It should only be setQueryData
or invalidateQueries
, not bothxenial-blackOP•9mo ago
Thanks for looking. Gotcha, yeah I added that invalidateQueries trying to get it to work. But I just also tried to await it and also not using invalidateQueries, but still no luck.
extended-yellow•9mo ago
Sometimes it's weird IDE preferences, but are you actually incrementing
data.id
as +data.id
or is that just a diff thingxenial-blackOP•9mo ago
that's unary operator I was wondering if it was a data type issue so I was converting all the ids to numbers, but I still have the same issue if I remove them all

extended-yellow•9mo ago
Hard to help with a screenshot of code. I'd check the dev tools to see if your query cache entries look right or make a minimal reproduction on codesandbox/stackblitz
xenial-blackOP•9mo ago
10-4. It's a react native project and I haven't even tried messing with query dev tools, but that's a good idea. I'll try to get that setup and dig around thanks
optimistic-gold•9mo ago
Make sure you're not accidentally mutating
old
!