bcgov / bcgov/react-shared-components

Ability to create controlled Input components.

Abierto
#484 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
4
Forks
2
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Comienza localizando el componente Input y leyendo cómo están implementados actualmente su valor actual y el comportamiento de defaultValue. Comprueba los ejemplos existentes de Storybook y las pruebas de Jest del componente, si las hay, y verifica después que los comportamientos controlado y no controlado solicitados estén cubiertos y documentados.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, react
Área
frontend
Tipo de issue
Nueva funcionalidad
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.