Handling prop defined in the argument list of stateless components

オープン
#457 コメント 0 件 リアクション 2 件 担当者 0 名 GitHub で見る

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript, react

調査の方向性

まず、react-docgen issue #69 に記載されている動作と、defaultProps の非推奨化に関するリンク先の議論を確認します。次に、コンポーネントの props 抽出のエントリーポイントを見つけ、分割代入された関数引数がどのように扱われるかを確認します。この構文で要求される prop 名と利用可能な型情報を文書化またはサポートできれば完了です。

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

説明

Dear all,

I'm struggling to find documentation about handling a case in which you're defining props in the arguments passed to a stateless, functional component, i.e. ES6 destructuring assignment syntax. An example:

const SomeComponent = ({ propA, propB, propC = 'someString', propD = false}) => {}

The most similar to what I'm looking for is https://github.com/reactjs/react-docgen/issues/69.

Now, docgen returns a list of props-defined-as-arguments as long as they have a default value specified, the rest is straight ignored.

My question: is some work being done on this? Any documentation I can find in this regard?

It seems fair and logical that it's hard to infer anything (but the name) from those props that have no explicit default value attributed to them, but as it stands even the types of the props that are initiated in the arguments, are omitted. You just get a stringified value for whatever is passed to them.

Thanks in advance!

Edit: tapped into the discussion on deprecating defaultProps -- https://github.com/reactjs/rfcs/pull/107#issuecomment-644582699

主要言語
TypeScript
スター
3.8k
フォーク
316
平均マージ
5時間 7分
マージ済み PR(30日)
4

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

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

はじめの一歩

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

reactjs/react-docgen のほかの issue

reactjs/react-docgen の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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