T
TanStack•3y ago
foreign-sapphire

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.
No description
No description
10 Replies
rare-sapphire
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-sapphire
foreign-sapphireOP•3y ago
ok thanks, thats so weird tho
sensitive-blue
sensitive-blue•3y ago
because the second argument is an object that has (additional) callbacks
fair-rose
fair-rose•3y ago
foreign-sapphire
foreign-sapphireOP•3y ago
Appreciate the hlep and pointing me to documentation
rare-sapphire
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
sensitive-blue•3y ago
can I tweet this 😂 ?
rare-sapphire
rare-sapphire•3y ago
Haha sure
sensitive-blue
sensitive-blue•3y ago
can obfuscate your handle if you want or mention you on twitter 😂
rare-sapphire
rare-sapphire•3y ago
Nah you're good have at it

Did you find this page helpful?