Skip to content

Clarifications about useMutation #344

Discussion options

You must be logged in to vote

useMutation is indeed built from similar control flow you have shown here, but it's built this way so that you can be more terse and declarative with your mutation-side effects where you declare your mutation logic instead of having to handle that control flow yourself in a try/catch/finally block. When you see an example like optimistic updates and rollbacks using onMutate, onError and onSuccess and all of the variable mapping that goes on between them, it's more clear that you would not want to write that on your own every time you need it, nor would I expect many to want to have to set up this logic on their own in some type of promise wrapper.

Other useful features beyond this are:

  • A…

Replies: 4 comments 11 replies

Comment options

You must be logged in to vote
4 replies
@patelnets
Comment options

@TkDodo
Comment options

@patelnets
Comment options

@TkDodo
Comment options

Answer selected by n1ghtmare
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
7 replies
@n1ghtmare
Comment options

@tannerlinsley
Comment options

@n1ghtmare
Comment options

@tannerlinsley
Comment options

@n1ghtmare
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants