Skip to content
Discussion options

You must be logged in to vote

but it seems like I was not be able to access the data/isLoading/isError in a different component even if I used the same mutationKey in useMutation.

results of mutations are currently not shared across components like the results of queries are. To access loading states of a mutation globally, you can use useIsMutating and filter it by mutation key.

usually, a mutation is somehow tied to a query. For example, in your case, you update the user entity, so usually, there is a useUserQuery that tries to query the user data from the server. So instead of trying to use the response of the mutation and access this globally, what you can also do is:

  • have output listen to the userQuery instead…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@saadq
Comment options

@TkDodo
Comment options

Answer selected by saadq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants