Files
2nd/10_Wiki/Topic_Programming/Architecture/Concurrent_Rendering.md
T
Antigravity Agent 9148c358d0 docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
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 폴더 제거.
2026-07-05 00:33:48 +09:00

175 lines
5.3 KiB
Markdown

---
id: wiki-2026-0508-concurrent-rendering
title: Concurrent Rendering
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [React Concurrent, Concurrent Mode, React 18 Concurrent]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [react, concurrent, rendering, scheduler, transitions]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: typescript
framework: react
---
# Concurrent Rendering
## 매 한 줄
> **"매 render 매 interruptible, prioritizable, abandonable"**. React 18 (2022) 에 stable. Fiber architecture (2017) 의 결실. 2026 현재 React 19+ 의 default; `useTransition`, `useDeferredValue`, Suspense, streaming SSR, React Compiler 매 모든 것 위에 빌드.
## 매 핵심
### 매 핵심 idea
- **Interruptible** — render 중 high-priority work (input, animation) 매 들어오면 yield.
- **Concurrent (NOT parallel)** — single-threaded JS 위에서 cooperative scheduling.
- **Time-slicing** — 5ms chunk 매 yield to browser (`scheduler` package).
- **Multiple in-progress trees** — current + work-in-progress; double buffering.
- **Lane-based priority** — sync, default, transition, idle lane.
### 매 hook / API
- **`useTransition`** — non-urgent update (filter, navigation).
- **`useDeferredValue`** — debounce-like, 매 lower priority value.
- **`startTransition`** — imperative version.
- **`Suspense`** — async boundary, fallback UI.
- **`use` hook** (React 19) — read promise during render.
### 매 응용
1. Search-as-you-type — input 매 sync, list filter 매 transition.
2. Tab switching — 매 instant feel, 매 expensive subtree 의 background render.
3. SSR streaming — 매 progressive shell + island hydration.
4. Route navigation — `<Link>` prefetch + transition.
## 💻 패턴
### useTransition — heavy filter
```tsx
function Search() {
const [query, setQuery] = useState('');
const [list, setList] = useState<Item[]>(allItems);
const [isPending, startTransition] = useTransition();
return (
<>
<input
value={query}
onChange={(e) => {
setQuery(e.target.value); // urgent
startTransition(() => { // non-urgent
setList(allItems.filter(i => i.name.includes(e.target.value)));
});
}}
/>
{isPending && <Spinner />}
<List items={list} />
</>
);
}
```
### useDeferredValue
```tsx
function Page({ query }: { query: string }) {
const deferred = useDeferredValue(query);
return <ExpensiveResults query={deferred} />;
}
```
### Suspense + use (React 19+)
```tsx
function UserProfile({ userPromise }: { userPromise: Promise<User> }) {
const user = use(userPromise); // suspends if pending
return <h1>{user.name}</h1>;
}
<Suspense fallback={<Skeleton />}>
<UserProfile userPromise={fetchUser(id)} />
</Suspense>
```
### Streaming SSR (Next.js 15 / React 19)
```tsx
// app/page.tsx
export default async function Page() {
return (
<>
<Header />
<Suspense fallback={<FeedSkeleton />}>
<Feed /> {/* streamed once data ready */}
</Suspense>
</>
);
}
```
### React Compiler (2026, automatic memoization)
```tsx
// no useMemo / useCallback needed — compiler inserts
function Cart({ items }: { items: Item[] }) {
const total = items.reduce((s, i) => s + i.price, 0); // auto-memoized
return <div>{total}</div>;
}
```
### Selective hydration
```tsx
// chat panel hydrates first if user clicks it,
// even if header is still loading
<Suspense fallback={<Sk />}>
<Header />
</Suspense>
<Suspense fallback={<Sk />}>
<Chat />
</Suspense>
```
### Cancel stale render (transition supersession)
```tsx
// older transition automatically discarded when new one starts
startTransition(() => setQuery('a')); // discarded
startTransition(() => setQuery('ab')); // wins
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| Input + heavy derived UI | `useTransition` |
| External lib slow value | `useDeferredValue` |
| Async data | `Suspense` + `use` |
| SSR with slow data | streaming + Suspense islands |
| Manual memoization (legacy) | replace with React Compiler |
**기본값**: React 19+ with Compiler; transitions for any non-urgent update.
## 🔗 Graph
- 부모: [[React]] · [[Rendering Pipeline]]
- 변형: [[Fiber_Architecture|Fiber Architecture]] · [[Time_Slicing|Time Slicing]]
- 응용: [[Streaming SSR]]
- Adjacent: [[Virtual DOM과 Reconciliation|Virtual DOM]] · [[Reconciliation]] · [[React Compiler]]
## 🤖 LLM 활용
**언제**: identify component 매 transition 으로 wrap 할 후보, code review 매 missed Suspense boundary.
**언제 X**: scheduler internals 의 deep debug (need devtools profiler).
## ❌ 안티패턴
- **`startTransition` for urgent input**: input lag.
- **No Suspense fallback**: 매 entire tree freeze 까지 falling back.
- **Manual memoization with React Compiler**: redundant + sometimes 더 느림.
- **Async setState in transition without race control**: stale data.
- **Deferred value of huge object reference**: 매 GC pressure.
## 🧪 검증 / 중복
- Verified (React 18 release notes 2022, React 19 docs 2026, Acdlite/Sebastian Markbåge talks).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — full content with React 19 + Compiler patterns |