Why am I able to only send one arguement to mutation function?
I'm currently working with the useMutation hook, and I'm encountering an issue. My mutation function expects two arguments, but when I use .mutate(firstArg, secondArg), only the first argument is being passed to my mutation function.


10 Replies
rare-sapphire•3y ago
I forget the reasoning behind it but you need to pass your variables as one object:
deleteSessionMutation.mutate({ sessionId, userId }) and change your deleteSession function to deconstruct them: deleteSession = async ({ sessionId, userId }) => {...}foreign-sapphireOP•3y ago
ok thanks, thats so weird tho
sensitive-blue•3y ago
because the second argument is an object that has (additional) callbacks
fair-rose•3y ago
Mastering Mutations in React Query
Learn all about the concept of performing side effects on the server with React Query.
foreign-sapphireOP•3y ago
Appreciate the hlep and pointing me to documentation
rare-sapphire•3y ago
I've come to learn if I have a question Dominik either already documented it or wrote a blog about it lol
sensitive-blue•3y ago
can I tweet this 😂 ?
rare-sapphire•3y ago
Haha sure
sensitive-blue•3y ago
can obfuscate your handle if you want
or mention you on twitter 😂
rare-sapphire•3y ago
Nah you're good have at it