Skip to content

Commit 39a78e9

Browse files
committed
fix: fallback showing too early
1 parent 1c1159b commit 39a78e9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/components/react-router-dom/ProtectedRoute.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ export default function ProtectedRoute({
9898
}
9999
}, [hasParams, isAuthenticated]);
100100

101+
// Show loading while checking router availability or auth/access
102+
if (isRouterAvailable === null || isLoading || accessLoading) {
103+
return <div>Loading...</div>;
104+
}
105+
101106
// Show loading while checking router availability
102107
if (isRouterAvailable === null) {
103108
return <div>Loading...</div>;
@@ -108,10 +113,6 @@ export default function ProtectedRoute({
108113
return <ProtectedRouteFallback>{children}</ProtectedRouteFallback>;
109114
}
110115

111-
if (isLoading || accessLoading) {
112-
return <div>Loading...</div>;
113-
}
114-
115116
if (!isAuthenticated) {
116117
return NavigateComponent ? (
117118
<NavigateComponent to={fallbackPath} replace />

0 commit comments

Comments
 (0)