From df61ce27e0a304daf054634da49c9744473b1d04 Mon Sep 17 00:00:00 2001 From: ThePotioner Date: Wed, 24 Sep 2025 15:43:34 +0900 Subject: [PATCH] refactor(routing): Migrate to React Router and simplify component structure Replaces 'wouter' with 'react-router-dom' to standardize the routing library and resolve dependency conflicts. Key changes: - All routing logic, including hooks (useLocation) and components (Link, Routes), now uses 'react-router-dom'. - The component tree has been simplified by removing the MainContainer component and moving its layout directly into App.tsx. - The provider is now correctly placed at the application's entry point in main.tsx. --- package.json | 3 +- src/App.tsx | 18 ++- src/components/MainContainer.tsx | 17 --- src/components/PageContainer.tsx | 14 +-- src/components/Sidebar.tsx | 8 +- .../{ToggleTheme.tsx => ThemeButton.tsx} | 2 +- src/components/Topbar.tsx | 7 +- src/main.tsx | 5 +- yarn.lock | 111 +++++++++++++----- 9 files changed, 118 insertions(+), 67 deletions(-) delete mode 100644 src/components/MainContainer.tsx rename src/components/{ToggleTheme.tsx => ThemeButton.tsx} (95%) diff --git a/package.json b/package.json index 8f5a1f1..a8dc365 100644 --- a/package.json +++ b/package.json @@ -19,9 +19,9 @@ "lucide-react": "^0.544.0", "react": "^19.1.1", "react-dom": "^19.1.1", + "react-router-dom": "^7.9.1", "tailwind-merge": "^3.3.1", "tailwindcss": "^4.1.13", - "wouter": "^3.7.1", "zustand": "^5.0.8" }, "devDependencies": { @@ -29,6 +29,7 @@ "@types/node": "^24.3.1", "@types/react": "^19.1.10", "@types/react-dom": "^19.1.7", + "@types/react-router-dom": "^5.3.3", "@vitejs/plugin-react-swc": "^4.1.0", "eslint": "^9.33.0", "eslint-plugin-react-hooks": "^5.2.0", diff --git a/src/App.tsx b/src/App.tsx index 7f04f98..7515a92 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,7 +1,17 @@ -import MainContainer from './components/MainContainer'; +import PageContainer from './components/PageContainer'; +import Sidebar from './components/Sidebar'; +import { ThemeButton } from './components/ThemeButton'; -function App() { - return ; -} +const App = () => { + return ( +
+ + +
+ +
+
+ ); +}; export default App; diff --git a/src/components/MainContainer.tsx b/src/components/MainContainer.tsx deleted file mode 100644 index cdafd67..0000000 --- a/src/components/MainContainer.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import PageContainer from './PageContainer'; -import Sidebar from './Sidebar'; -import { ToggleTheme } from './ToggleTheme'; - -const MainContainer = () => { - return ( -
- - -
- -
-
- ); -}; - -export default MainContainer; diff --git a/src/components/PageContainer.tsx b/src/components/PageContainer.tsx index 1bd7997..ccd5c49 100644 --- a/src/components/PageContainer.tsx +++ b/src/components/PageContainer.tsx @@ -1,4 +1,4 @@ -import { Route, Switch } from 'wouter'; +import { Routes, Route } from 'react-router-dom'; import Topbar from './Topbar'; @@ -11,12 +11,12 @@ const PageContainer = () => { return (
- - - - - - + + } /> + } /> + } /> + } /> +
); }; diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 4fb7a75..10cce81 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -1,5 +1,5 @@ import { Button } from '@/components/ui/button'; -import { useLocation, Link } from 'wouter'; +import { Link, useLocation } from 'react-router-dom'; import { IconHome, IconCalendarWeekFilled, @@ -16,7 +16,7 @@ export const items = [ ]; const Sidebar = () => { - const [location] = useLocation(); + const location = useLocation(); return (