Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot refetch user data once logged in #27

Open
ThanvirBasik opened this issue Mar 27, 2023 · 4 comments
Open

Cannot refetch user data once logged in #27

ThanvirBasik opened this issue Mar 27, 2023 · 4 comments

Comments

@ThanvirBasik
Copy link

How do we refetch an user once their state has changed to logged in?

@machour
Copy link

machour commented Mar 27, 2023

Just like you would invalidate any query of react-query, by invalidating its key.

Here's the key of the useUser() query: https://github.com/alan2207/react-query-auth/blob/master/src/index.tsx#L37 ([authenticated-user])

so queryClient.invalidateQueries(["authenticated-user"]) should do the trick here.
See also https://tanstack.com/query/v3/docs/react/guides/query-invalidation

@StevenOng97
Copy link

StevenOng97 commented May 5, 2023

Hi @machour, @alan2207 it's not working on my side :/

@machour
Copy link

machour commented May 5, 2023

A small repo reproducing the issue would help a lot understanding what's going on

@ThanvirBasik
Copy link
Author

ThanvirBasik commented May 10, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants