reactjs / reactjs/react.dev

[Suggestion]: Document using Promises passed from RSC to the client without `use()`

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

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

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

説明

Summary

The docs on RSC should mention whether Promises passed from Server Components can be used without use().

Page

https://react.dev/reference/rsc/server-components

Details

Currently, the docs only discuss resolving Promises passed from the server using use(). Sometimes it can be useful to render a component with partial data and update its state once the promise is fulfilled. This appears to work.:

"use client";

export default function Component({ promise }) {
  const [data, setData] = useState(null);
  useEffect(() => {
    let canceled = false;
    promise.then((d) => !canceled && setData(d));

    return () => canceled = true;
  }, [promise])

  return (<p>{data}</p>);
}

However I can't find any mentions of this use case. I think that if this is officially supported, there should be an example showing how to do it. And if not, that should be explicitly stated.

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

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

はじめの一歩

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

調査の方向性

https://react.dev/reference/rsc/server-components の Server Components ページから始め、client components に渡される Promises について現在どのように説明されているかを確認します。示されているユースケースが公式にサポートされているかどうかを判断し、例を使って文書化するか、サポートされていないことを明示します。ページでこのユースケースが明確に扱われれば完了です。

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

評価

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

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

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