Skip to content

Commit

Permalink
refactor: 각각의 컴포넌트를 Suspense로 묶도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Cllaude99 committed Dec 3, 2024
1 parent bba6c4a commit 11f0254
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions packages/frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Routes, Route, createBrowserRouter, RouterProvider } from 'react-router-dom';
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
import { lazy, Suspense, useEffect } from 'react';
import Layout from '@/components/layout/Layout';
import LoadingSpinner from '@/components/common/LoadingSpinner';
Expand All @@ -18,23 +18,29 @@ const router = createBrowserRouter([
index: true,
element: (
<PublicRoute>
<LandingPage />
<Suspense fallback={<LoadingSpinner />}>
<LandingPage />
</Suspense>
</PublicRoute>
),
},
{
path: 'lobby',
element: (
<PrivateRoute>
<LobbyPage />
<Suspense fallback={<LoadingSpinner />}>
<LobbyPage />
</Suspense>
</PrivateRoute>
),
},
{
path: 'game/:gsid',
element: (
<PrivateRoute>
<GamePage />
<Suspense fallback={<LoadingSpinner />}>
<GamePage />
</Suspense>
</PrivateRoute>
),
},
Expand All @@ -55,11 +61,7 @@ function App() {
};
}, []);

return (
<Suspense fallback={<LoadingSpinner />}>
<RouterProvider router={router} />
</Suspense>
);
return <RouterProvider router={router} />;
}

export default App;

0 comments on commit 11f0254

Please sign in to comment.