bcgov / bcgov/react-shared-components

Ability to create controlled Input components.

オープン
#484 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
4
フォーク
2
PR マージ指標
30日以内にマージされた PR はありません

説明

**Is your feature request related to a problem? Please describe.**
The current version of the Input component doesn't allow you to pass in values to the _value_ attribute, only to the _defaultValue_ attribute. This prevents developers from creating Input components that are controlled by passing in state to the value attribute.

**Describe the solution you'd like**
I would like the option to pass in a prop that gets passed into the value attribute on the input tag. One way I was thinking this could be done is by adding a prop called isControlled that determines whether the value passed into the value prop is passed down to the value or the defaultValue attribute.

If isControlled=true, pass the component's value prop to the value attribute on the input tag.
If isControlled=false, pass the component's value prop to the defaultValue attribute on the input tag. (This is how it currently works).

**Describe alternatives you've considered**
Another alternative would be to add another prop that is passed directly to value. However, this would allow developers to pass values to both value and defaultValue at the same time, which is considered a bad practice in React, and will generate warnings in the console.

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

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

まず Input コンポーネントを見つけ、現在の値と defaultValue の動作がどのように実装されているかを確認します。コンポーネントに既存の Storybook の例と Jest のテストがあれば確認し、要求された controlled と uncontrolled の動作がカバーされ、文書化されていることを検証します。

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

評価

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

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

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