|
1 | 1 | import React, { useEffect, useState } from 'react'; |
2 | 2 | import { BrowserRouter, Route, Routes, Navigate } from 'react-router-dom'; |
3 | | -import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; |
4 | 3 |
|
5 | 4 | import Home from '@pages/Home'; |
6 | 5 | import Login from '@pages/Login'; |
@@ -33,8 +32,6 @@ import { getUserInfoApi } from '@apis/user'; |
33 | 32 | import { getCurrentUserId } from '@utils/getCurrentUserId'; |
34 | 33 | import Loading from '@components/Loading'; |
35 | 34 |
|
36 | | -const queryClient = new QueryClient(); |
37 | | - |
38 | 35 | const ProtectedRoute = ({ children }: { children: JSX.Element }) => { |
39 | 36 | const [isAuthenticated, setIsAuthenticated] = useState<boolean | null>(null); |
40 | 37 |
|
@@ -101,24 +98,22 @@ const publicRoutes = [ |
101 | 98 |
|
102 | 99 | const App: React.FC = () => { |
103 | 100 | return ( |
104 | | - <QueryClientProvider client={queryClient}> |
105 | | - <BrowserRouter> |
106 | | - <Routes> |
107 | | - {/* 인증이 필요한 페이지 */} |
108 | | - {protectedRoutes.map(({ path, element }) => ( |
109 | | - <Route key={path} path={path} element={<ProtectedRoute>{element}</ProtectedRoute>} /> |
110 | | - ))} |
111 | | - |
112 | | - {/* 인증이 필요 없는 페이지 */} |
113 | | - {publicRoutes.map(({ path, element }) => ( |
114 | | - <Route key={path} path={path} element={element} /> |
115 | | - ))} |
116 | | - |
117 | | - {/* 없는 페이지에 대한 처리 */} |
118 | | - <Route path="*" element={<NotFound />} /> |
119 | | - </Routes> |
120 | | - </BrowserRouter> |
121 | | - </QueryClientProvider> |
| 101 | + <BrowserRouter> |
| 102 | + <Routes> |
| 103 | + {/* 인증이 필요한 페이지 */} |
| 104 | + {protectedRoutes.map(({ path, element }) => ( |
| 105 | + <Route key={path} path={path} element={<ProtectedRoute>{element}</ProtectedRoute>} /> |
| 106 | + ))} |
| 107 | + |
| 108 | + {/* 인증이 필요 없는 페이지 */} |
| 109 | + {publicRoutes.map(({ path, element }) => ( |
| 110 | + <Route key={path} path={path} element={element} /> |
| 111 | + ))} |
| 112 | + |
| 113 | + {/* 없는 페이지에 대한 처리 */} |
| 114 | + <Route path="*" element={<NotFound />} /> |
| 115 | + </Routes> |
| 116 | + </BrowserRouter> |
122 | 117 | ); |
123 | 118 | }; |
124 | 119 |
|
|
0 commit comments