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
mutationFn
some options that I set when I calluseMutation()
.I noticed that if I use a
function
keyword function (and not an arrow function, of course), thethis
parameter insideonMutate
andmutationFn
have 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
this
frommutationFn
?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