reactjs / reactjs/react.dev

Code splitting: React.lazy() example is missing a Suspense wrapper

オープン
#1,810 コメント 7 件 リアクション 15 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
JavaScript
スター
11.8k
フォーク
7.9k
平均マージ
1日 11時間
マージ済み PR(30日)
11

説明

I'm not quite sure if this is intentional to only demonstrate how React.lazy() is used, if the API how lazy() works was changed after that part of the docs have been written already, if I am using it incorrectly or if it is actually wrong but in the example but in the code splitting guide you're using a component wrapped in a React.lazy() and do not wrap it in a <Suspense>:

https://reactjs.org/docs/code-splitting.html#reactlazy

When I do that I get an error message:

A React component suspended while rendering, but no fallback UI was specified.

Source

Two paragraphs later Suspense is introduced and then a working example is shown where the lazy-loaded component is correctly wrapped in <Suspense> but I don't know if it is a good idea to have a non-functioning example in the documentation in the first place as it might be misleading.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

リンク先のURLにあるコード分割ガイドのReact.lazyセクションを読み、その例を後のSuspenseの例と比較してください。リンク先のCodeSandboxを使って動作を再現し、その後、lazy-loadingの例が正確になり、必要なfallback UIについて読者に誤解を与えないようにドキュメントを更新してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, react
領域
documentation
issue の種類
ドキュメント
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
55/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。