bcgov / bcgov/react-shared-components

Ability to create controlled Input components.

Offen
#484 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
4
Forks
2
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

**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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Beginne damit, die Input-Komponente zu finden und zu lesen, wie ihr aktueller Wert und das Verhalten von defaultValue derzeit implementiert sind. Prüfe die vorhandenen Storybook-Beispiele und Jest-Tests der Komponente, sofern vorhanden, und verifiziere anschließend, dass die angeforderten kontrollierten und unkontrollierten Verhaltensweisen abgedeckt und dokumentiert sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, react
Bereich
frontend
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.