Consolidate useMutation API to use the object pattern? #3127
Replies: 2 comments 2 replies
-
It was actually on our roadmap for v4 to remove all overloads and only use a single object for useQuery and useMutation. However, we got stopped by a known typescript limitation where TS has troubles with type inference in certain situations, which would be worse. For reference: microsoft/TypeScript#43371 (comment) |
Beta Was this translation helpful? Give feedback.
-
I was looking whether "object syntax" variant But original question was unanswered:
Are we right? Shall we update doc to state that I'm happy to open PR, it should be trivial. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
While browsing the
react-query
docs foruseMutation
the example shown is the version ofuseMutation
that takes themutationFn
as it's first argument.There is also the version of
useMutation
that takes in an object (UseMutationOptions
), but is not shown on the website docs (it is with typescript types & editor autocomplete)I think the
useMutation
call using theUseMutationOptions
object might have a few more benefits than the other available ways to call theuseMutation
hook:I imagine that the reason we have multiple ways to call
useMutation
is for backwards compatibility & historical purposes. In the future, do you think it is worth or even feasible consolidating theuseMutationAPI
?What do you think about me updating the docs examples to use the passing of the object approach?
Beta Was this translation helpful? Give feedback.
All reactions