react-query-auth icon indicating copy to clipboard operation
react-query-auth copied to clipboard

Cannot refetch user data once logged in

Open ThanvirBasik opened this issue 2 years ago • 4 comments

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

ThanvirBasik avatar Mar 27 '23 06:03 ThanvirBasik

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

machour avatar Mar 27 '23 10:03 machour

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

StevenOng97 avatar May 05 '23 15:05 StevenOng97

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

machour avatar May 05 '23 17:05 machour

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: @.***>

ThanvirBasik avatar May 10 '23 04:05 ThanvirBasik