We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4b7938d commit 3341925Copy full SHA for 3341925
1 file changed
src/App.tsx
@@ -30,6 +30,7 @@ import MatchingRoom from '@pages/Chats/MatchingRoom';
30
import NotFound from '@pages/NotFound';
31
import { getUserInfoApi } from '@apis/user';
32
import { getCurrentUserId } from '@utils/getCurrentUserId';
33
+import Loading from '@components/Loading';
34
35
const ProtectedRoute = ({ children }: { children: JSX.Element }) => {
36
const [isAuthenticated, setIsAuthenticated] = useState<boolean | null>(null);
@@ -43,6 +44,10 @@ const ProtectedRoute = ({ children }: { children: JSX.Element }) => {
43
44
checkAuth();
45
}, []);
46
47
+ if (isAuthenticated === null) {
48
+ return <Loading />;
49
+ }
50
+
51
return isAuthenticated ? children : <Navigate to="/login" />;
52
};
53
0 commit comments