T
TanStack•3w ago
rare-sapphire

Pass custom data to mutate function

Hi I have a custom hook wrapping useMutation. onSuccess callback is used to invalidate some qeries and show a notification. Basically this notificaitons is needed for each call except one. Can I pass a condition to onSuccess so I can control the behaviour when calling mutate() ? thanks
3 Replies
extended-salmon
extended-salmon•3w ago
You can control it via variables that you pass to mutate because onSuccess also has access to variables
rare-sapphire
rare-sapphireOP•3w ago
great. thank you
fascinating-indigo
fascinating-indigo•3w ago
Not my Q to post on but I always forget that - thank you @TkDodo 🔮 ! I always rely on the return val.

Did you find this page helpful?