Type is not assignable to type mutate function
Hello all, I get this error
and I am unsure how to fix it. I followed the same pattern as my createDummy function, both of which write react query functions to make mutation calls to the database.

14 Replies
sensitive-blue•2y ago
mutationFn only provides one parameter. You'll need to combine dummyId and dummy under one objectsensitive-blue•2y ago
Mastering Mutations in React Query
Learn all about the concept of performing side effects on the server with React Query.
sensitive-blue•2y ago
If your
updateDummy method must be that way, you could do:
And invoke via something like:
rival-blackOP•2y ago
Thank you @troywoy for your reply
Should I be spreading the contents of the dummy object?
sensitive-blue•2y ago
Depends on how you call
mutaterival-blackOP•2y ago
I'd like to keep the params for the createDummy api call unchanged:
When I implement this code change:
sensitive-blue•2y ago
And how do you call mutate from
useUpdateDummyMutation?rival-blackOP•2y ago
I get new TS error properties don't exist on type 'void'
sensitive-blue•2y ago
You need to type the
({ dummyId, dummy }) => portionsensitive-blue•2y ago
TS Playground - An online editor for exploring TypeScript and JavaS...
The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.
sensitive-blue•2y ago
That's a sloppy example
rival-blackOP•2y ago
I call useMutate as part of a long form submission, here's the relevant part:
sensitive-blue•2y ago
You have two options there.
Either spread
...dummy on the mutateAsync line:
Or put dummyId onto the const dummy object and simply use that:
rival-blackOP•2y ago
@troywoy thank you very much. You have helped immensely.