When mutate after an action, to want to get the request list, use queryCache. RefetchQueries or queryCache. InvalidateQueries list update, but did not make the list updates.Neither approach works
See original GitHub issue` export const useTouchListComplate = () => {
const [mutate] = useMutation((options: any) => {
return fetch(${DOMAIN.BIBLE_INSPIRE}${PATH.WORKBENCH.API_LIST_COMPLATE}
, {
method: ‘POST’,
body: objToParam({
deptcode: options.deptcode,
list_code: options.list_code
})
})
}, {
onSuccess: (data: any, param: any) => {
console.log(data)
queryCache.refetchQueries(${DOMAIN.BIBLE_INSPIRE}${PATH.WORKBENCH.API_TABLE_EACH_DATA}/${param.tabId}
, {
active: true
})
}
})
return [
mutate
]
}
`
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top Results From Across the Web
When mutate after an action, to want to get the request list, use ...
RefetchQueries or queryCache. InvalidateQueries list update, but did not make the list updates.Neither approach works #1081.
Read more >React-Query and Query Invalidation Question - Stack Overflow
The mutation does not automatically triggers a refetch. The way to achieve this using react-query is via queryCache.invalidateQueries to ...
Read more >Refetching queries in Apollo Client - Apollo GraphQL Docs
The InMemoryCache helps you determine which active queries might have been invalidated by recent cache updates. Local cache updates and refetching work ......
Read more >Query Invalidation | TanStack Query Docs
For that purpose, the QueryClient has an invalidateQueries method that lets you intelligently mark queries as stale and potentially refetch them too! `tsx....
Read more >React Query Tutorial - 22 - Query Invalidation - YouTube
Your browser can 't play this video. Learn more.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Not sure I got the question right, but here are some approaches to what I think you want to achieve that have been working well for me:
You can see this working in this example: https://react-query.tanstack.com/docs/examples/optimistic-updates
especially this part:
this approach will manually update the cache with the data from the server, so it will not re-fetch it. This is useful if, like in my example, your server already returns the new data as a result of the mutation request.
Since you have
suspense
set totrue
, maybe this is a duplicate of https://github.com/tannerlinsley/react-query/issues/1065 ?