Can I use use the this parameter on callbacks such as onMutate and mutationFn?
#9398
Unanswered
tringenbach
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am looking for a way to access from inside my default
mutationFnsome options that I set when I calluseMutation().I noticed that if I use a
functionkeyword function (and not an arrow function, of course), thethisparameter insideonMutateandmutationFnhave the fields I need!But, I couldn't find that documented anywhere. So I would like to know if this is something I can rely on, or if it is more of an accident that could change at any time.
(Unfortunately I was having trouble searching for
this, since it's such as a generic word.)Is it safe to access
thisfrommutationFn?If not, is there any other way to get at the options passed to
useMutation()from inside themutationFn?Beta Was this translation helpful? Give feedback.
All reactions