function useThirdPartyMutation() {
const mutation = useMutation({
mutationFn: ...,
onSuccess: async () => {
console.log("third party on success")
},
)
// Only returns subset of the mutation fields, which is kind of an unfortunate decision, but not really relevant to my question, I think...
return { ... }
}
// In my app...
function SomeComponent() {
const thirdPartyMutation = useThirdPartyMutation()
const myWrapperMutation = useMutation({
mutationFn: async () => {
return thirdPartyMutation.mutateAsync()
},
onSuccess: async () => {
console.log("wrapper on success")
}),
// Other options that explain why this wrapper is being used
...
})
}
function useThirdPartyMutation() {
const mutation = useMutation({
mutationFn: ...,
onSuccess: async () => {
console.log("third party on success")
},
)
// Only returns subset of the mutation fields, which is kind of an unfortunate decision, but not really relevant to my question, I think...
return { ... }
}
// In my app...
function SomeComponent() {
const thirdPartyMutation = useThirdPartyMutation()
const myWrapperMutation = useMutation({
mutationFn: async () => {
return thirdPartyMutation.mutateAsync()
},
onSuccess: async () => {
console.log("wrapper on success")
}),
// Other options that explain why this wrapper is being used
...
})
}