Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix/#543] RouteTracker 호출 위치 변경 #545

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import ResponsiveProvider from './components/commons/Responsive/ResponsiveProvid
import Loading from './pages/loading/Loading';

import router from './routers/Router';
import RouteTracker from './routers/RouteTracker';
import { MOBILE_MEDIA_QUERY } from './styles/mediaQuery';

const App = () => {
Expand All @@ -27,7 +26,6 @@ const App = () => {
<DesktopWrapper>
<Suspense fallback={<Loading />}>
<RouterProvider router={router} />
<RouteTracker />
</Suspense>
</DesktopWrapper>
</ResponsiveProvider>
Expand Down
2 changes: 2 additions & 0 deletions src/components/commons/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Outlet } from 'react-router-dom';
import RouteTracker from '../../routers/RouteTracker';
import ScrollToTop from './ScrollToTop';

const Layout = () => {
return (
<>
<RouteTracker />
<ScrollToTop />
<Outlet />
</>
Expand Down
10 changes: 9 additions & 1 deletion src/routers/PrivateRoute.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { Navigate, Outlet, useLocation } from 'react-router-dom';

import checkAuthenticate from '../utils/checkAuthenticate';
import RouteTracker from './RouteTracker';

const PrivateRoute = () => {
const pathname = useLocation();
if (!checkAuthenticate()) {
alert('로그인 후 이용이 가능합니다.');
}
return checkAuthenticate() ? <Outlet /> : <Navigate to="/login" state={pathname} />;
return checkAuthenticate() ? (
<>
<RouteTracker />
<Outlet />
</>
) : (
<Navigate to="/login" state={pathname} />
);
};
export default PrivateRoute;
Loading