Components that suspend inside a transition load one after another instead of in parallel
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript
- 領域
- frontend
調査の方向性
Start by reading the transition runner in dom/transitions.ts and tracing how handleSuspended handles a promise during a transition render. Use the provided Suspense reproduction to observe when each load starts. Done means sibling loads start in the same pass while the transition still waits for the promises and commits the same result. The issue links a fix commit, so check its status before starting.
索引モデルが issue の本文から書いたものです。
説明
On our website, each component loads its translations lazily: the first render for a locale starts a dynamic import() and throws the promise. Switching locale is wrapped in startTransition.
With React, the switch takes a single round trip. With redact enabled, the old page stays on screen for several seconds, and the network tab shows the chunks fetched strictly one after another (14 chunks, around 5s in production).
Repro
const cache = new Map<string, Promise<string>>()
const load = (key: string) => {
if (!cache.has(key)) {
console.log('start', key)
cache.set(key, fetchText(key))
}
return cache.get(key)!
}
const Text = ({ name, locale }) => <span>{use(load(`${name}-${locale}`))}</span>
const Page = () => {
const [locale, setLocale] = useState('en')
return (
<>
<button onClick={() => startTransition(() => setLocale('fr'))}>fr</button>
<Text name="a" locale={locale} />
<Text name="b" locale={locale} />
<Text name="c" locale={locale} />
</>
)
}
// click "fr"
// React: start a-fr, start b-fr, start c-fr
// redact: start a-fr ... (a-fr resolves) ... start b-fr ... (b-fr resolves) ... start c-fr
Cause
During a transition render,
handleSuspendedthrows the promise straight up to the transition runner (tindom/transitions.ts), which rewinds and retries once that one promise settles. The siblings after the suspended component never render in that pass, so their own loads only start on the next retry. React keeps rendering the siblings of a suspended component (prewarming), so every load starts in the same pass.
Fix
When a held transition suspends on a new promise, render the same fibers once more without throwing (the suspended component renders nothing and its siblings keep going), then rewind that pass. It only starts the work, what the transition waits for and what gets committed don't change.
Fix: https://github.com/aymericzip/redact/commit/18464d7
Related issue: https://github.com/TanStack/redact/issues/137
- 主要言語
- TypeScript
- スター
- 581
- フォーク
- 28
- 平均マージ
- 13時間 48分
- マージ済み PR(30日)
- 45
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TanStack/redact のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
TanStack/redact#142 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 20/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
メンテナーはふだん 1 日以内に返信
TanStack/redact の issue をすべて見る
似ている issue
-
inference/go type/feature
難易度 1/5 1〜3時間 初心者へのやさしさ 72/100
anomalyco/opencode#65148 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
truapi-release
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
paritytech/product-sdk#529 ·
メンテナーはふだん 1 日以内に返信
-
Add: Mansudae TVオープンapproved check:passed streams:add
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
-
[Perf] Canvas layer composition is quadratic: splitRenderLayers re-copies the node array per nodeオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
devlikeapro/waha#2369 ·
メンテナーはふだん 5 日以内に返信