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] - lazy loading 제거 #558

Merged
merged 1 commit into from
Oct 23, 2024
Merged
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
53 changes: 8 additions & 45 deletions frontend/src/router.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { Suspense, lazy } from "react";
import { createBrowserRouter } from "react-router-dom";

import { css } from "@emotion/react";

import { Spinner, Text } from "@components/common";
import AppLayout from "@components/layout/AppLayout/AppLayout";
import KakaoCallbackPage from "@components/pages/login/KakaoCallbackPage";
import LoginPage from "@components/pages/login/LoginPage";
Expand All @@ -12,47 +8,14 @@ import MyPage from "@components/pages/my/MyPage";
import NotFoundPage from "@components/pages/notFound/NotFoundPage";
import SearchPage from "@components/pages/search/SearchPage";
import TravelPlanDetailPage from "@components/pages/travelPlanDetail/TravelPlanDetailPage";
import TravelPlanEditPage from "@components/pages/travelPlanEdit/TravelPlanEditPage";
import TravelPlanRegisterPage from "@components/pages/travelPlanRegister/TravelPlanRegisterPage";
import TravelogueDetailPage from "@components/pages/travelogueDetail/TravelogueDetailPage";
import TravelogueEditPage from "@components/pages/travelogueEdit/TravelogueEditPage";
import TravelogueRegisterPage from "@components/pages/travelogueRegister/TravelogueRegisterPage";

import { ROUTE_PATHS_MAP } from "./constants/route";

const TravelogueRegisterPage = lazy(
() => import("@components/pages/travelogueRegister/TravelogueRegisterPage"),
);
const TravelogueEditPage = lazy(
() => import("@components/pages/travelogueEdit/TravelogueEditPage"),
);
const TravelPlanRegisterPage = lazy(
() => import("@components/pages/travelPlanRegister/TravelPlanRegisterPage"),
);
const TravelPlanEditPage = lazy(
() => import("@components/pages/travelPlanEdit/TravelPlanEditPage"),
);

const lazyLoadingFallbackStyle = css`
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
height: 100vh;
max-width: 48rem;
gap: 1rem;
`;

const withLazyLoading = (Component: React.ComponentType) => (
<Suspense
fallback={
<div css={lazyLoadingFallbackStyle}>
<Spinner />
<Text textType="bodyBold">로딩 중이에요. 잠시만 기다려주세요 :)</Text>
</div>
}
>
<Component />
</Suspense>
);

export const router = createBrowserRouter([
{
path: ROUTE_PATHS_MAP.root,
Expand All @@ -76,23 +39,23 @@ export const router = createBrowserRouter([
},
{
path: ROUTE_PATHS_MAP.travelogueRegister,
element: withLazyLoading(TravelogueRegisterPage),
element: <TravelogueRegisterPage />,
},
{
path: ROUTE_PATHS_MAP.travelogueEdit(),
element: withLazyLoading(TravelogueEditPage),
element: <TravelogueEditPage />,
},
{
path: ROUTE_PATHS_MAP.travelPlan(),
element: <TravelPlanDetailPage />,
},
{
path: ROUTE_PATHS_MAP.travelPlanRegister,
element: withLazyLoading(TravelPlanRegisterPage),
element: <TravelPlanRegisterPage />,
},
{
path: ROUTE_PATHS_MAP.travelPlanEdit(),
element: withLazyLoading(TravelPlanEditPage),
element: <TravelPlanEditPage />,
},
{
path: ROUTE_PATHS_MAP.my,
Expand Down
Loading