[Documentation] Add information about `child.key` to `React.Children.map`
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 11.8k
- フォーク
- 7.9k
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 11
説明
I just spent quite a while debugging a performance issue when reordering a large list of components, which were wrapped in React.Children.map.
The issue was the implementation of the wrapping component, which used the index as the key, which caused the entire list to re-render from scratch:
<div>
{React.Children.map(props.children, (child, index) => (
<div key={index} className='...'>{child}</div>
))}
</div>
The solution was to use child.key and pass it into the child-component, which then, in turn, made the memoization of the child components work as expected:
<div>
{React.Children.map(props.children, (child) => (
<div key={child.key} className='...'>{child}</div>
))}
</div>
I feel like this should be mentioned somewhere on the documentation page for React.Children.map, since I only figured out that this is possible at all after specifically searching for it and finding #10432.
I'm happy to update the docs in a PR if this gets the OK :)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Issue にリンクされている React API ドキュメントページの React.Children.map セクションから始め、issue #10432 の関連する議論を確認してください。child.key と、children をラップする際にそれが重要である理由について明確な情報を追加し、その後、ドキュメントで意図された使用方法とパフォーマンス上の考慮事項が説明されていることを確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, react
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 55/100