How to update response cache when using useMutation #5850
Unanswered
yokoyama-takuya
asked this question in
Q&A
Replies: 3 comments 10 replies
-
I think you want this: https://tanstack.com/query/v4/docs/react/guides/updates-from-mutation-responses |
Beta Was this translation helpful? Give feedback.
0 replies
-
@TkDodo Thank you for your reply. I want to update mutation's cache. const mutation = useMutation<{ list: { data: string }[] }>({})
if (mutation.data?.list) {
// I want to change this `mutation.data.list`
} |
Beta Was this translation helpful? Give feedback.
1 reply
-
also have this problem. it looks like mutations don't expose any |
Beta Was this translation helpful? Give feedback.
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Thanks for awesome library!
I want to update mutation's cache without refetching, is that possible? like
queryClient.setQueryData
.https://tanstack.com/query/latest/docs/react/reference/QueryClient#queryclientsetquerydata
I know can use any HTTP request method by
useQuery's queryFn
anduseMutation's mutationFn
.Even if POST method's API, I should use
useQuery
?The API is only search, but using POST method becase have many request parametes.
Beta Was this translation helpful? Give feedback.
All reactions