Better way to uncontrolled components?
オープン
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 11.8k
- フォーク
- 7.9k
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 11
説明
Hi, in the documentation for uncontrolled components it is shown that we could use ref to access the values in the form, it is not specified why we shouldn't use this approach instead:
const App = () => {
const file = useRef()
const submit = (e) => {
e.preventDefault()
const form = new FormData(e.target)
form.append('archivo', file.current.files[0])
console.log(Array.from(form))
// even better:
Object.fromEntries(Array.from(form))
}
return (
<form onSubmit={submit}>
<div>
<span>lala</span>
<input defaultValue='my value' type='text' name='field' />
<input type='file' ref={file} />
</div>
<input type='submit' value='Enviar' />
</form>
)
}
I think it's way cleaner as we only have to focus one one potential value, an input of type file. Is there a reason to not use it?
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
content/docs/uncontrolled-components.md から始め、特に refs とフォームの値について説明しているセクションを確認し、リンクされた例をレビューしてください。ドキュメント内で、提案されている FormData と file-ref のアプローチを使用すべきかどうか、またその理由を明確にし、そのうえでページに非制御フォームに対する明確な推奨が示されていることを確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, react
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100