Files
2nd/10_Wiki/Topics/Architecture/Concurrent_Rendering.md
T
Antigravity Agent f8b21af4be Wiki cleanup: error-doc removal, dedup merge, link normalization
10_Wiki/Topics 대규모 정리:
- 오류 캡처/미완성 stub 문서 227개 제거
- 교차폴더 중복 43클러스터 병합 (63파일 → redirect)
- 링크명 정규화: 깨진 링크 수정·redirect 직결·개념 매핑 ~2,400건
- 카테고리 MOC 6개 신규 생성
- Graph 섹션 미해결 related-keyword 링크 10,058건 제거

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 23:52:15 +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 |