Learn how to handle identity management in React by creating a global state for your authentication details with Context and update these details with Hooks.
Nice tutorial. I’ve gone through to the end but I keep getting the following error in console:
Unhandled Promise Rejection: null
Clearly there is something wrong either in the .env file or in the settings of the Auth0 app. Could you provide more details on what settings you need to get this working in the Auth0 app. For example, does http://localhost:3000 need to be entered into the CORS setting?
As it stands now, I’ll get the error in the console as soon as I start the app, and when I press login, the browser loads https://dev-5-vlv7-y.auth0.com/ (my app domain) with a login form.
Hello, Peter! Welcome to the Auth0 community. I see what you mean! I am getting the same message in the Dev Console. Part of that is that the Promise has no catch element and also that on page load the handleAuthentication method is not successful.
Let me revise the code. I think it will also be best to update this blog post to use our latest Auth0 SPA SDK. I’ll be working on this. As the weekend is soon approaching, I’ll give you an update by next week Wednesday. How does this sound?
Hello, Peter! I sincerely apologize that I forgot to give you an update. We are working on revamping the guidance for React Context and Hooks. I don’t have an ETA yet but the Research and Development is in progress I’ll be updating this thread and the blog post once it’s ready
Hello, Przemysław Welcome to our Auth0 Community. We continue working on this and we’ll provide updated guidance on the React space in the near future. We want to ensure we get it right and tested before we publish it
Same issue Maybe you should put a note at the top of the article so people don’t waste a lot of time implementing the code in the article only to have problems?
Hello, Brendan, welcome to our Auth0 Community. I apologize for that. You are right, your time is valuable and we want you to receive full benefit from our guidance without hitting speed bumps or blockers. I am going to escalate this internally and have a solution ASAP. If we cannot work on a full blog post for it, we should at least provide you with a working sample app
Oops sorry, I didn’t mean to be quite so direct. Thanks for the tutorials, they help a lot. Anyway, I was looking around and I think your docs themselves are really good for this particular use case, i.e.: Auth0 React SDK Quickstarts: Login I’m pretty new to react so I’m probably missing something.
You are fine, Brendan! It’s valid and solid feedback. I do suggest at the time being to refer to that React QS for our latest guidance. I am discussing with my team internally what position we should take here as this blog post is using the older library, auth0-js. I think it’s best to provide guidance for both libraries as auth0-js is still commonly used. But, if you want to start with the latest, that React QS is a good point to start: it’s using Context and Hooks.
I’ll be working on adding a note based on your feedback. I think that’s a good addition to the blog post Thank you again for bringing that up!
1- it’s about old context API and less about how to use auth0.
2- it’s an old auth0 sdk is Dan trying to explain how to use and you won’t know that until you read the comments.