Skip to content

Commit

Permalink
refactor: ProtectedRoutes에서 로그인 여부를 boolean 값이 아닌 토큰 값으로 확인하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
areumH committed Jan 22, 2025
1 parent 79812fc commit 44aeb67
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const App: React.FC = () => {
const navigate = useNavigate();

const isMobile = useIsMobile();
const isLoggedIn = !!useNewSelector(selectAccessToken);
const accessToken = useNewSelector(selectAccessToken);
const isTokenRefreshing = useNewSelector(selectIsRefreshing);

useEffect(() => {
Expand Down Expand Up @@ -96,7 +96,7 @@ const App: React.FC = () => {
<Route path={PATH.SEARCH.GAME} element={<SearchGamePage />} />
</Route>

<Route element={<ProtectedRoutes isLoggedIn={isLoggedIn} />}>
<Route element={<ProtectedRoutes token={accessToken} />}>
<Route path={PATH.MYPAGE} element={<LayoutNoFooter />}>
<Route index element={<MyPage />} />
</Route>
Expand Down
6 changes: 3 additions & 3 deletions src/components/Routes/ProtectedRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { PATH } from '@/constants/path';
import { Navigate, Outlet } from 'react-router-dom';

type Props = {
isLoggedIn: boolean;
token: string | undefined;
};

const ProtectedRoutes = ({ isLoggedIn }: Props) => {
return isLoggedIn ? <Outlet /> : <Navigate to={PATH.LOGIN} />;
const ProtectedRoutes = ({ token }: Props) => {
return token ? <Outlet /> : <Navigate to={PATH.LOGIN} />;
};

export default ProtectedRoutes;

0 comments on commit 44aeb67

Please sign in to comment.