use-auth0-hooks
use-auth0-hooks copied to clipboard
On page load, if not logged in, isLoading is always true
Everything is working wonderfully, except... when I load my app without a user logged in, and am checking for isLoading, it gets set to true but never gets set to false. With a logged in user on a fresh page load it works as expected –– is true while setting the session, then is set to false.
It's crucial to be able to check isLoading even when a user is not logged in. To me it makes sense that on initialization it's set to true, but once it's determined the user is not in fact logged in or logging in, it should be set to false.
+1 I'm also seeing this.
@icco have you had any luck here? May pull it down again and try and get it working locally to see what's up. I had issues doing that at first try because it's typescript and my app isn't (or something along those lines). It seems even when logged in, the isLoading flag is not reliably set to false when everything is complete.
So I finally got this working last night. My logic is at https://github.com/icco/writing/blob/master/lib/auth.js. also check out pages/_app.js and components/Header.js
@icco thanks! I'm not using graphql/apollo so will have to sort through some of the magic you're using with lazy query... but I think the idea makes sense? Thanks for sharing.
I'm observing both behaviors described here when audience and scope are provided to useAuth:
isLoadingsometimes remainstruewhen logged in and the access token is fetchedisLoadingstaystruewhen logged out
@sandrinodimattia is this intentional behavior or a bug?
I'm having exactly the same behavior as you @derrickreimer, isLoading behaves erratically.
I think that @sandrinodimattia has abandoned this repo, the latest commit was on December 5th.
I'm using @msembinelli's fork (https://github.com/msembinelli/use-auth0-hooks) that fixes #22 and seems to be actively maintained.
We could try to resolve the issue on his repo and kind of make it the de-facto fork.
What do you think guys?
Hi @ngirardin I am already thinking about making an official package for mine under a new name, I will keep you updated. Does the isLoading work for you on my fork?
I am willing to get this fixed and maintain it on mine as I am actively consuming it for a project.
Edit: looking into this and hope to have a fix in the next couple of days Edit2: I can no longer product this bug, can someone verify if this issue still persists on my fork?
Hi @msembinelli, sorry for the late reply!
I'll be actively working on integrating Auth0 on our app for the next days, I'm gonna test your fork (https://github.com/msembinelli/use-auth0-hooks) and keep you updated here.
Hi @msembinelli, I'm using your fork for a few days and the isLoading behavior is better.
It works when the user is not authenticated, and when the page is called by the Auth0 callback, but once the user is authenticated, isLoading is always true.
@ngirardin I'm not seeing this occur on my end. When user gets set, isLoading should be toggled. I might have to dig into this one a bit more. Is there anything you can provide as far as examples snippets and logs go?
@msembinelli I think that my cache was in a weird state, I cleared it and it worked
All of the concepts of this library have been moved to the official Auth0 SDK for React (https://github.com/auth0/auth0-react), so I'll be archiving this repository shortly.