Invalidation from Mutations not working #3317
Unanswered
youneshajji
asked this question in
Q&A
Replies: 1 comment
-
please try to provide that in a codesandbox reproduction |
Beta Was this translation helpful? Give feedback.
0 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.
-
Hi,
I have implemented the Invalidation from Mutations but it doesnt seem to be working for me, when i invalidate from devtools manually it works fine. After i trigger a mutation and switch browser panes back and forth, i can see the data changes in the UI. What am i missing :)
Here is my code:
const userProfileQuery = useQuery(
"userProfileData",
() =>
fetchApi(process.env.REACT_APP_API_URL_APIM + "/Contacts", account, inProgress, instance).then((res) => res.data),
{
onSuccess: (data) => {
...
},
onError: (_error) => {
toast.error(_error.message, {
position: "top-center",
})
},
}
)
const mutationUpdate = useMutation(
() => {
patchApi(
process.env.REACT_APP_API_URL_APIM + "/Contacts/me",
{
...
},
account,
inProgress,
instance
)
},
{
onSuccess: async () => {
queryClient.invalidateQueries("userProfileData")
},
onError: (_error) => {
toast.error(_error.message, {
position: "top-center",
})
},
onSettled: () => {
hideShowSpans(false)
onToggleEdit()
toast.success("Profilen din er oppdatert!", {
position: "top-center",
})
},
}
)
Beta Was this translation helpful? Give feedback.
All reactions