ampproject / ampproject/amp-react-prototype
Property change states
- Lenguaje dominante
- JavaScript
- Estrellas
- 36
- Forks
- 6
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
Use case: ``. The `currentSlide` is currently a "state" value and this is preferable. We could consider making it a controlled property coupled with `onSlideChange` callback, but that'd expand the API surface for something very simple. However, what should happen if the `currentSlide` prop (or "current-slide" attribute in DOM) has been updated? The simplified [useStateFromProp](https://github.com/ampproject/amp-react-prototype/blob/104861c3777d5341377092620f123b9013c0050d/src/amp-react-utils.js#L32) hook supports updating the internal state when a prop changes, but it's not without issues. For instance, assuming the default prop/attribute value of `currentSlide = 0`, if the `currentSlide` state has been updated and the script simply wants to reset it back to the first slide, setting the `currentSlide` back to `0` will not work since technically the property's value will not change.
Guía de contribución
Línea de trabajo
Comienza con el hook useStateFromProp en src/amp-react-utils.js, en la línea enlazada, y luego inspecciona cómo amp-carousel expone currentSlide y current-slide. Aclara el comportamiento deseado cuando un valor se restablece a su valor de prop existente; para darlo por terminado, deben acordarse la interacción entre property y state y el alcance de la implementación.
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
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100