Skip to content

Commit 3341925

Browse files
committed
fix: isAuthenticated가 업데이트되기 전에 return하는 문제 해결
1 parent 4b7938d commit 3341925

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/App.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import MatchingRoom from '@pages/Chats/MatchingRoom';
3030
import NotFound from '@pages/NotFound';
3131
import { getUserInfoApi } from '@apis/user';
3232
import { getCurrentUserId } from '@utils/getCurrentUserId';
33+
import Loading from '@components/Loading';
3334

3435
const ProtectedRoute = ({ children }: { children: JSX.Element }) => {
3536
const [isAuthenticated, setIsAuthenticated] = useState<boolean | null>(null);
@@ -43,6 +44,10 @@ const ProtectedRoute = ({ children }: { children: JSX.Element }) => {
4344
checkAuth();
4445
}, []);
4546

47+
if (isAuthenticated === null) {
48+
return <Loading />;
49+
}
50+
4651
return isAuthenticated ? children : <Navigate to="/login" />;
4752
};
4853

0 commit comments

Comments
 (0)