9148c358d0
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
167 lines
5.5 KiB
Markdown
167 lines
5.5 KiB
Markdown
---
|
|
id: wiki-2026-0508-fiber-architecture
|
|
title: Fiber Architecture
|
|
category: 10_Wiki/Topics
|
|
status: verified
|
|
canonical_id: self
|
|
aliases: [React Fiber, Reconciler]
|
|
duplicate_of: none
|
|
source_trust_level: A
|
|
confidence_score: 0.9
|
|
verification_status: applied
|
|
tags: [react, frontend, reconciliation]
|
|
raw_sources: []
|
|
last_reinforced: 2026-05-10
|
|
github_commit: pending
|
|
tech_stack:
|
|
language: typescript
|
|
framework: react
|
|
---
|
|
|
|
# Fiber Architecture
|
|
|
|
## 매 한 줄
|
|
> **"매 reconciliation 을 interruptible 한 unit 으로 쪼갠다"**. 매 React 16 (2017) 에서 stack reconciler 를 대체 — 매 work loop 가 매 fiber node 단위로 yield 가능하므로 매 concurrent rendering, Suspense, transitions 의 토대. 2026 React 19 의 Server Components, Actions, `use` hook 모두 매 fiber tree 위에서 동작.
|
|
|
|
## 매 핵심
|
|
|
|
### 매 fiber node
|
|
- 매 React element 1:1 의 mutable bookkeeping object.
|
|
- 매 `child / sibling / return` pointer 로 tree linkage (매 array 가 아닌 linked list).
|
|
- `pendingProps`, `memoizedProps`, `memoizedState`, `effectTag`, `lanes`.
|
|
- 매 두 tree: **current** (committed) + **workInProgress** (next render) — 매 double buffering.
|
|
|
|
### 매 work loop
|
|
1. **Render phase** (interruptible) — 매 beginWork → completeWork DFS, 매 frame budget 만료 시 yield.
|
|
2. **Commit phase** (synchronous) — 매 DOM mutation, ref attach, layout effect.
|
|
3. **Lanes** — 매 priority bitmask (Sync, Default, Transition, Idle).
|
|
|
|
### 매 응용
|
|
1. `useTransition` / `useDeferredValue` — 매 low-priority lane.
|
|
2. Suspense boundary — 매 throw promise → fallback render.
|
|
3. Server Components (RSC) — 매 server fiber 의 serialize.
|
|
4. Concurrent rendering / time slicing.
|
|
|
|
## 💻 패턴
|
|
|
|
### Fiber node 의 shape (개념)
|
|
```ts
|
|
type Fiber = {
|
|
type: any; key: string | null;
|
|
child: Fiber | null; sibling: Fiber | null; return: Fiber | null;
|
|
alternate: Fiber | null; // current ↔ workInProgress
|
|
pendingProps: any; memoizedProps: any; memoizedState: any;
|
|
flags: number; // Placement | Update | Deletion
|
|
lanes: number; childLanes: number;
|
|
stateNode: any; // DOM node | class instance
|
|
};
|
|
```
|
|
|
|
### Work loop (개념)
|
|
```ts
|
|
function workLoopConcurrent() {
|
|
while (workInProgress !== null && !shouldYield()) {
|
|
workInProgress = performUnitOfWork(workInProgress);
|
|
}
|
|
}
|
|
function performUnitOfWork(fiber: Fiber): Fiber | null {
|
|
const next = beginWork(fiber.alternate, fiber, renderLanes);
|
|
if (next === null) return completeUnitOfWork(fiber);
|
|
return next;
|
|
}
|
|
```
|
|
|
|
### useTransition (React 19)
|
|
```tsx
|
|
import { useTransition, useState } from "react";
|
|
|
|
export function Search() {
|
|
const [query, setQuery] = useState("");
|
|
const [results, setResults] = useState<string[]>([]);
|
|
const [isPending, startTransition] = useTransition();
|
|
|
|
return (
|
|
<>
|
|
<input value={query} onChange={e => {
|
|
setQuery(e.target.value); // sync lane
|
|
startTransition(() => setResults(filter(e.target.value))); // transition lane
|
|
}}/>
|
|
{isPending ? <Spinner/> : <List items={results}/>}
|
|
</>
|
|
);
|
|
}
|
|
```
|
|
|
|
### Suspense + use (React 19)
|
|
```tsx
|
|
import { Suspense, use } from "react";
|
|
|
|
function Profile({ promise }: { promise: Promise<User> }) {
|
|
const user = use(promise); // 매 throw 시 Suspense fallback
|
|
return <h1>{user.name}</h1>;
|
|
}
|
|
|
|
export default () => (
|
|
<Suspense fallback={<Skeleton/>}>
|
|
<Profile promise={fetchUser()}/>
|
|
</Suspense>
|
|
);
|
|
```
|
|
|
|
### Server Component (RSC)
|
|
```tsx
|
|
// app/page.tsx — 매 server fiber, payload 로 serialize
|
|
export default async function Page() {
|
|
const posts = await db.posts.findMany();
|
|
return <PostList posts={posts}/>; // 매 client 로는 RSC payload 전송
|
|
}
|
|
```
|
|
|
|
### useDeferredValue
|
|
```tsx
|
|
const deferred = useDeferredValue(query); // 매 stale value 로 render, urgent update 우선
|
|
```
|
|
|
|
### Lane priority debug (React DevTools)
|
|
```
|
|
Profiler tab → Highlight transitions → 매 어느 lane 에서 commit 됐는지 확인
|
|
```
|
|
|
|
## 매 결정 기준
|
|
| 상황 | Approach |
|
|
|---|---|
|
|
| 즉시 반영 input | 직접 setState (sync lane) |
|
|
| 무거운 list filter | startTransition (transition lane) |
|
|
| Async data 의 render | Suspense + use |
|
|
| Server-only data fetch | RSC (`async function Page`) |
|
|
| Stale UI 허용 + responsive | useDeferredValue |
|
|
|
|
**기본값**: React 19 + RSC (Next.js App Router), client side 는 transition + Suspense.
|
|
|
|
## 🔗 Graph
|
|
- 부모: [[React]] · [[Reconciliation]]
|
|
- 변형: [[React Server Components — 경계 의식]] · [[Concurrent Features|Concurrent Rendering]]
|
|
- 응용: [[Suspense]] · [[useTransition]] · [[useDeferredValue]] · [[Streaming SSR]]
|
|
- Adjacent: [[Virtual DOM과 Reconciliation|Virtual DOM]] · [[Hydration]]
|
|
|
|
## 🤖 LLM 활용
|
|
**언제**: 매 jank 진단, transition vs sync 결정, Suspense boundary 위치 reasoning.
|
|
**언제 X**: 매 non-React framework — 매 Vue / Svelte / Solid 는 매 다른 reconciler.
|
|
|
|
## ❌ 안티패턴
|
|
- **Sync setState in event for heavy work**: 매 main thread block.
|
|
- **Suspense without boundary**: 매 root crash — 매 ErrorBoundary + Suspense pair.
|
|
- **useTransition for urgent input**: 매 typing latency 발생.
|
|
- **Mutating fiber internals**: 매 React 의 internal — 매 forward-compat 보장 X.
|
|
- **Effect 의 setState loop**: 매 무한 render — 매 dependency 정확히.
|
|
|
|
## 🧪 검증 / 중복
|
|
- Verified (React 19 release notes, Andrew Clark *fiber* RFC, React docs 2026, Vercel RSC docs).
|
|
- 신뢰도 A.
|
|
|
|
## 🕓 Changelog
|
|
| 날짜 | 변경 |
|
|
|---|---|
|
|
| 2026-05-08 | Phase 1 |
|
|
| 2026-05-10 | Manual cleanup — fiber + lanes + React 19 (RSC, use, transition) 정리 |
|