Skip to content
Discussion options

You must be logged in to vote

Maybe I misunderstood and instead of using useQuery in this case I should use useMutation with a GET request in it?

It really depends on what you want to do. Is your request executing side-effects on the backend, like logging in a user? Then it's most certainly a mutation. Be aware that mutations really only run once when you invoke them. Queries on the other hand can re-fetch for a variety of reasons after you enable them. So for example, a window focus event could trigger a refetch. If it's truly a GET request, it doesn't matter because they are idempotent.

Also, ask yourself if you want to share data across components, because useMutation cannot do that out of the box.

Is the above …

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by TkDodo
Comment options

You must be logged in to vote
1 reply
@TkDodo
Comment options

Comment options

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

@TkDodo
Comment options

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