Auth0 Provider beforeLoad Implementation #1322
allan-vera
started this conversation in
General
Replies: 1 comment 1 reply
-
You could conditionally render the RouterProvider after the authentication library has finished loading. function App() {
const auth = useAuth();
if (auth.isLoading) {
return <AuthLoadingMessage />
}
return <RouterProvider router={router} context={{ auth }} />
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello. I am running into an issue where my
beforeLoad
function is running before my AuthProvider finishes loading.My Auth Provider hook provides the following values:
isLoading
,isAuthenticated
, and theuser
object.I pass in
isAuthenticated
to the Router via its context. However, by defaultisAuthenticated
isfalse
while it loads. By the time myprotectRoute
function runs (mybeforeLoad
function), its still loading and thus get redirected to /login. How do get it to wait until the AuthProvider has finished loading?Beta Was this translation helpful? Give feedback.
All reactions