Skip to content
This repository has been archived by the owner on Jun 23, 2020. It is now read-only.

On page load, if not logged in, isLoading is always true #14

Open
benheb opened this issue Dec 29, 2019 · 12 comments
Open

On page load, if not logged in, isLoading is always true #14

benheb opened this issue Dec 29, 2019 · 12 comments

Comments

@benheb
Copy link

benheb commented Dec 29, 2019

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.

@icco
Copy link

icco commented Jan 5, 2020

+1 I'm also seeing this.

@benheb
Copy link
Author

benheb commented Jan 9, 2020

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

@icco
Copy link

icco commented Jan 9, 2020

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

@benheb
Copy link
Author

benheb commented Jan 10, 2020

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

@derrickreimer
Copy link

I'm observing both behaviors described here when audience and scope are provided to useAuth:

  • isLoading sometimes remains true when logged in and the access token is fetched
  • isLoading stays true when logged out

@sandrinodimattia is this intentional behavior or a bug?

@ngirardin
Copy link

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?

@msembinelli
Copy link

msembinelli commented Apr 21, 2020

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?

@ngirardin
Copy link

ngirardin commented May 8, 2020

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.

@ngirardin
Copy link

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.

@msembinelli
Copy link

@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?

@ngirardin
Copy link

@msembinelli I think that my cache was in a weird state, I cleared it and it worked

tsaiDavid added a commit to matternet/use-auth0-hooks that referenced this issue Jun 16, 2020
@sandrinodimattia
Copy link
Owner

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.

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

No branches or pull requests

6 participants