Derived State: Fully uncontrolled component with a key
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 11.8k
- フォーク
- 7.9k
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 11
説明
Hi,
In the article You Probably Don't Need Derived State, one of the recommended ways to avoid deriving state from props, is to have "Fully uncontrolled component with a key".
However, there is no way to actually force the user to provide a 'key' property to the component, since declaring it in propTypes as "key: PropTypes.any.isRequired" won't work, because it's value is always 'undefined', which leads to a warning message:
Warning: MyComponent:
keyis not a prop. Trying to access it will result inundefinedbeing returned. If you need to access the same value within the child component, you should pass it as a different prop.
And without declaring the 'key' prop type, we cannot assume, that the user will use the component in a proper manner.
How to mitigate this?
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされている「You Probably Don't Need Derived State」の記事と、key へのアクセスに関して報告されている PropTypes 警告から始めてください。key を持つ完全に非制御のコンポーネントについて、ドキュメントに明確化が必要かどうかを判断してください。完了の条件は、記事で有効な回避策を説明するか、制限事項を明示的にドキュメント化することです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, react
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100