Refetching queries does not work
I'm trying to refetch some queries after one success but it's not working!
I used two ways to handle it by using refetchQueries() / invalidateQueries()
1- onSuccess callback
second way
sample of query I wanted to refetch after the success
8 Replies
stormy-goldOP•3y ago
After using Debug tool
react-query-native-devtools
I have bottom tabs
any query in the first screen is not recorded in the debug tool!!stormy-goldOP•3y ago
Anonymous
VEED
VEED - Project Name
Make stunning videos with a single click. Cut, trim, crop, add subtitles and more. Online, no account needed. Try it now, free. VEED
stormy-goldOP•3y ago
When I change the default tab to the second one and navigate from tab 2 to tab 1, I can see all tab 1 queries executed in the debugger
sensitive-blue•3y ago
Is there already a query in the cache with key ‘getNewOrders’ when you do the mutation?
adverse-sapphire•3y ago
because I'm seeing
enabled here: If the query is not enabled, it will not be targeted by refetchQueries / invalidateQueries. The only way to refetch a disabled query is by using refetch returned from useQuery.
if your query is enabled, it should work.stormy-goldOP•3y ago
@mark salsbery no
@TkDodo 🔮 But the enabled is
true
(the token already exists)!
and the data comes from the API "if you saw the video"
it also not be targeted by refetchQueries / invalidateQueries?
And now i delete the enabled
and still, the issue exists!
Nothing was recorded in the debugger, and
refetchQueries / invalidateQueries not worksadverse-sapphire•3y ago
could be one of those issues: https://tkdodo.eu/blog/react-query-fa-qs#why-are-updates-not-shown
otherwise, please show a reproduction.
React Query FAQs
Answering the most frequently asked React Query questions
sensitive-blue•3y ago
@Anas Without a matched key already cached then I wouldn’t expect reFetch or invalidate to do anything…useQuery should work though 😉