refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게 [공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류. 문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인). - Topic_Programming → Domain_Programming (내부 구조 보존) - Topic_Graphic → Domain_Design - Topic_Business → Domain_Product - Topic_General → Domain_General - _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning), Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing) - 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서) - 빈 폴더 정리 (memory/procedures) - 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
---
|
||||
id: react-router-patterns
|
||||
title: React Router — 데이터 로딩 통합 패턴
|
||||
category: Coding
|
||||
status: draft
|
||||
source_trust_level: B
|
||||
verification_status: conceptual
|
||||
created_at: 2026-05-09
|
||||
updated_at: 2026-05-09
|
||||
tags: [react, routing, data-loading, vibe-coding]
|
||||
tech_stack: { language: "TypeScript / React Router 6+ / Next.js", applicable_to: ["Web"] }
|
||||
applied_in: []
|
||||
aliases: [loader, action, nested routes, prefetch]
|
||||
---
|
||||
|
||||
# React Router 데이터 로딩 통합
|
||||
|
||||
> 라우트 = URL 매칭만이 아니라 **데이터 로딩 / 검증 / 권한 / 코드 분할의 단위**. RR6 loader/action 또는 Next.js page/layout 모두 같은 철학 — "이 화면이 필요한 모든 것을 라우트가 선언".
|
||||
|
||||
## 📖 핵심 개념
|
||||
- **loader**: 라우트 진입 시 병렬 fetch. 컴포넌트 렌더 전 완료.
|
||||
- **action**: form POST 등 mutation. 완료 후 자동 revalidate.
|
||||
- **nested routes**: 부모 layout 유지 + 자식 영역만 교체.
|
||||
- **prefetch on hover**: 사용자가 클릭하기 전 다음 화면 데이터 미리.
|
||||
|
||||
## 💻 코드 패턴
|
||||
|
||||
```tsx
|
||||
// React Router 6 — data router
|
||||
const router = createBrowserRouter([
|
||||
{
|
||||
path: '/users/:id',
|
||||
loader: async ({ params }) => {
|
||||
const [user, posts] = await Promise.all([
|
||||
fetchUser(params.id!),
|
||||
fetchPosts(params.id!),
|
||||
]);
|
||||
return { user, posts };
|
||||
},
|
||||
action: async ({ request, params }) => {
|
||||
const data = Object.fromEntries(await request.formData());
|
||||
await updateUser(params.id!, data);
|
||||
return redirect(`/users/${params.id}`);
|
||||
},
|
||||
Component: UserPage,
|
||||
errorElement: <ErrorPage />,
|
||||
},
|
||||
]);
|
||||
|
||||
function UserPage() {
|
||||
const { user, posts } = useLoaderData() as Awaited<ReturnType<typeof loader>>;
|
||||
return <Profile user={user} posts={posts} />;
|
||||
}
|
||||
```
|
||||
|
||||
```tsx
|
||||
// Prefetch on hover
|
||||
<Link to="/users/1" prefetch="intent">User</Link>
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준
|
||||
| 화면 | 데이터 도구 |
|
||||
|---|---|
|
||||
| 정적 / 빌드 시 알려진 | SSG (Next static) |
|
||||
| 사용자별 + SEO 필요 | SSR (loader) |
|
||||
| 사용자별 + SEO 무관 (대시보드) | Client fetch (RR loader 도 OK) |
|
||||
| Form 제출 | action / Server Action |
|
||||
| 공유 layout | nested route + Outlet |
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **컴포넌트 안 useEffect fetch + setState**: waterfall + 깜빡임. loader 가 부모 + 자식 병렬.
|
||||
- **path param 검증 누락**: `/users/abc` 도 통과. zod 검증 + 404.
|
||||
- **action 에서 직접 DB write 대신 API 호출**: 한 번 더 hop. Server Action 또는 직접.
|
||||
- **pending UI 없음**: 클릭 후 무반응. `useNavigation().state === 'loading'` 으로 표시.
|
||||
- **Link prefetch 모든 곳**: 데이터/번들 폭증. 'intent' (hover) 가 균형.
|
||||
- **에러 boundary 누락**: 404/500 처리 없음. errorElement 또는 Next error.tsx.
|
||||
|
||||
## 🤖 LLM 활용 힌트
|
||||
- 화면 1개 = 1 라우트 + loader + action + errorElement 4종 세트.
|
||||
- prefetch='intent' 디폴트.
|
||||
|
||||
## 🔗 관련 문서
|
||||
- [[React_Suspense_for_Data]]
|
||||
- [[React_Error_Boundary]]
|
||||
Reference in New Issue
Block a user