-
Notifications
You must be signed in to change notification settings - Fork 1
[Init] router 세팅 #10
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
[Init] router 세팅 #10
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR sets up the initial React Router configuration for the application, transitioning from a basic Vite React template to a proper routing setup using react-router-dom v7.
- Installs react-router-dom v7 and configures basic routing structure
- Creates shared router configuration with path constants and route definitions
- Implements basic page components for home, login, and error handling
- Removes default Vite template code and styling
Reviewed Changes
Copilot reviewed 9 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/shared/router/path.ts | Defines path constants for routing |
| src/shared/router/index.tsx | Creates browser router configuration with route mappings |
| src/pages/home/home-page.tsx | Basic home page component |
| src/pages/login/login-page.tsx | Basic login page component |
| src/pages/error/error-page.tsx | Basic error page component |
| src/app/App.tsx | Replaces default template with RouterProvider |
| src/app/App.css | Removes default Vite styling |
| src/app/index.css | Removes default Vite styling |
| package.json | Adds react-router-dom dependency |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Walkthrough라우팅을 도입했다. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User as User/Browser
participant Router as RouterProvider
participant RRD as createBrowserRouter
participant Home as HomePage
participant Login as LoginPage
participant Err as ErrorPage
User->>Router: URL 접속(/, /login, 기타)
Router->>RRD: 매칭 요청
alt path == "/"
RRD-->>Router: Home route
Router->>Home: 렌더
else path == "/login"
RRD-->>Router: Login route
Router->>Login: 렌더
else 기타
RRD-->>Router: Error route("*")
Router->>Err: 렌더
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
src/pages/error/error-page.tsx (1)
1-5: 초기 설정으로는 적절합니다.에러 페이지의 기본 구조가 올바르게 설정되었습니다. 향후 개선 사항으로는 실제 에러 정보 표시,
useRouteError훅 활용, 사용자 친화적인 에러 메시지 추가를 고려해보세요.src/shared/router/index.tsx (1)
7-11: 라우터 설정이 올바르게 구현되었습니다.
createBrowserRouter를 사용한 라우터 구성이 정확합니다. 향후 코드 스플리팅을 위해 lazy loading을 고려해보세요.예시 (lazy loading 적용):
-import HomePage from "../../pages/home/home-page"; -import LoginPage from "../../pages/login/login-page"; -import ErrorPage from "../../pages/error/error-page"; +import { lazy } from "react"; + +const HomePage = lazy(() => import("../../pages/home/home-page")); +const LoginPage = lazy(() => import("../../pages/login/login-page")); +const ErrorPage = lazy(() => import("../../pages/error/error-page")); export const router = createBrowserRouter([ { path: PATH.HOME, element: <HomePage /> }, { path: PATH.LOGIN, element: <LoginPage /> }, { path: PATH.ERROR, element: <ErrorPage /> }, ]);lazy loading을 사용하는 경우 App.tsx에서
<Suspense>래퍼를 추가해야 합니다.src/app/App.tsx (1)
1-5: 라우터 통합이 올바르게 완료되었습니다.
RouterProvider를 통한 라우터 설정이 정확합니다. 향후 에러 핸들링 개선을 위해 Error Boundary 추가를 고려해보세요.예시 (Error Boundary 추가):
import { RouterProvider } from "react-router-dom"; import { router } from "../shared/router"; import { ErrorBoundary } from "react-error-boundary"; const App = () => ( <ErrorBoundary fallback={<div>앱 에러가 발생했습니다.</div>}> <RouterProvider router={router} /> </ErrorBoundary> ); export default App;src/shared/router/path.ts (1)
1-5: 경로 상수 설정이 올바르게 구현되었습니다.
as const어서션을 사용한 타입 좁히기가 정확하며, ERROR 경로의 와일드카드 패턴("*")도 적절합니다.향후 타입 안정성 향상을 위해 경로 타입을 추출하여 활용할 수 있습니다:
export const PATH = { HOME: "/", LOGIN: "/login", ERROR: "*", } as const; export type PathKey = keyof typeof PATH; export type PathValue = typeof PATH[PathKey];
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (9)
package.json(1 hunks)src/app/App.css(0 hunks)src/app/App.tsx(1 hunks)src/app/index.css(0 hunks)src/pages/error/error-page.tsx(1 hunks)src/pages/home/home-page.tsx(1 hunks)src/pages/login/login-page.tsx(1 hunks)src/shared/router/index.tsx(1 hunks)src/shared/router/path.ts(1 hunks)
💤 Files with no reviewable changes (2)
- src/app/App.css
- src/app/index.css
🧰 Additional context used
🧬 Code graph analysis (2)
src/shared/router/index.tsx (1)
src/shared/router/path.ts (1)
PATH(1-5)
src/app/App.tsx (1)
src/shared/router/index.tsx (1)
router(7-11)
🔇 Additional comments (4)
src/pages/home/home-page.tsx (1)
1-5: LGTM!홈 페이지 컴포넌트가 올바르게 구현되었습니다. 초기 라우터 설정 단계로는 충분합니다.
src/pages/login/login-page.tsx (1)
1-5: LGTM!로그인 페이지 컴포넌트가 올바르게 구현되었습니다. 초기 라우터 설정으로는 충분합니다.
package.json (1)
16-16: [email protected] 게시 확인됨
npm 레지스트리에서 해당 버전이 존재함을 확인했습니다.src/shared/router/index.tsx (1)
3-5: tee 명령어가 없어 build.log가 생성되지 않았습니다. 아래 명령으로 다시 확인해주세요:pnpm build > build.log 2>&1 grep -E "error.*(import|resolve|module)" build.log && echo "Import errors detected" || echo "Build successful"
📌 Related Issue
✅ Checklist
📚 Tasks
📷 Screenshot
Summary by CodeRabbit