Add an option to omit default props that are empty function callbacks

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

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

評価

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

調査の方向性

まず、リポジトリ内で showDefaultProps と filterProps のオプションをたどり、JSX 文字列の生成時にデフォルトの prop 値がどのように比較されるかを調べます。showDefaultProps または別のドキュメント化されたオプションによって空の関数コールバックを省略できる方法を追加し、生成された出力からそれらのコールバックが除外され、他の prop に影響しないことを確認します。

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

説明

Often times a callback prop is assigned an empty function (() => {}) as the default value. The showDefaultProps method is simply looking for equality (I believe), so it won't catch a default prop that is just an empty function. In those cases, I had to add some logic in the filterProps property to make those not appear but I don't think this is the best solution and I would love it if the showDefaultProps would catch those as well or if there was another option I can set so those empty functions don't show up in the generated string.

filterProps: value => {
  // Omit empty functions (they're likely from default props and `showDefaultProps` doesn't catch those)
  if (!isFunction(value)) {
    return true;
  }

  return value.toString() !== '() => {}';
},
主要言語
TypeScript
スター
519
フォーク
88
平均マージ
3時間 55分
マージ済み PR(30日)
1

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

algolia/react-element-to-jsx-string のほかの issue

algolia/react-element-to-jsx-string の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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