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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello. I am running into an issue where my
beforeLoadfunction is running before my AuthProvider finishes loading.My Auth Provider hook provides the following values:
isLoading,isAuthenticated, and theuserobject.I pass in
isAuthenticatedto the Router via its context. However, by defaultisAuthenticatedisfalsewhile it loads. By the time myprotectRoutefunction runs (mybeforeLoadfunction), 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