T
TanStack3y ago
correct-apricot

Conditional mutationFn in useMutation

Is it possible to create a custom useMutation like the following with the correct typescript ?
export const useCustomMutation = <T extends Types>({ type }: { type: T }) => {
return useMutation({
mutationFn: type === 'one' ? one : two,
});
export const useCustomMutation = <T extends Types>({ type }: { type: T }) => {
return useMutation({
mutationFn: type === 'one' ? one : two,
});
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?