react-query-auth
react-query-auth copied to clipboard
Cannot refetch user data once logged in
How do we refetch an user once their state has changed to logged in?
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
Hi @machour, @alan2207 it's not working on my side :/
A small repo reproducing the issue would help a lot understanding what's going on
I tried whatever you sent and it worked for me. Great work, keep going!
From: Mehdi Achour @.> Sent: Friday, May 5, 2023 10:35 PM To: alan2207/react-query-auth @.> Cc: Thanvir Ibrahim @.>; Author @.> Subject: Re: [alan2207/react-query-auth] Cannot refetch user data once logged in (Issue #27)
A small repo reproducing the issue would help a lot understanding what's going on
— Reply to this email directly, view it on GitHubhttps://github.com/alan2207/react-query-auth/issues/27#issuecomment-1536541598, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A6JT7DDIJ2UPLYWXF66WJQLXEUXO7ANCNFSM6AAAAAAWIXHHZU. You are receiving this because you authored the thread.Message ID: @.***>