[Mistakes]: Server Functions examples use incompatible action signatures
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 11.8k
- フォーク
- 7.9k
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 11
説明
Summary
The updateName Server Function is defined as updateName(name), but the page later uses it as a direct form action and with useActionState. These usages pass different arguments, so the examples cannot work with the shown function.
Page
https://react.dev/reference/rsc/server-functions
Details
The page defines:
export async function updateName(name) {
if (!name) {
return {error: 'Name is required'};
}
await db.users.updateName(name);
}
There are several inconsistencies/mistakes:
-
In “Server Functions with Actions”, the input does not update the
namestate, soupdateName(name)always receives''. -
On success,
updateNamereturnsundefined, but the client destructures{error}from its result. -
When passed to
<form action={updateName}>, React callsupdateNamewithFormData, not a string. -
When passed to
useActionState, React calls it with(previousState, FormData), and it must consistently return the next state.
The examples should define a Server Function with the correct parameters and return value for each usage.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
https://react.dev/reference/rsc/server-functions の Server Functions リファレンスページから始め、「Server Functions with Actions」、直接のフォームアクション、useActionState の使用における updateName の例を比較します。各例のパラメーターと戻り値が、FormData 引数と前の状態の引数を含め、React がそれを呼び出す方法と一致すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, react
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 静か
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 74/100