Skip to content
Discussion options

You must be logged in to vote

invalidateQueries does a refetch already, however, it will refetch with the old id, because the userId is not part of the query key. I would:

  • use ["Me", id] as querykey
  • call removeQueries on ["Me"] after successful login to remove all data from other users
  • then do the router push, which will:
    • redirect to a page that picks up useMe
    • which will make the request with the correct id.

if you want to fetch before you do the redirect, I would do that with queryClient.prefetchQueries

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@nemanjam
Comment options

@TkDodo
Comment options

@nemanjam
Comment options

Answer selected by nemanjam
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