bcgov / bcgov/react-shared-components
Ability to create controlled Input components.
- Lingua principale
- JavaScript
- Stelle
- 4
- Fork
- 2
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
**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.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Inizia individuando il componente Input e leggendo come sono attualmente implementati il suo valore corrente e il comportamento di defaultValue. Controlla gli esempi Storybook e i test Jest esistenti del componente, se presenti, quindi verifica che i comportamenti controllato e non controllato richiesti siano coperti e documentati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, react
- Ambito
- frontend
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100