ampproject / ampproject/amp-react-prototype
Property change states
- Lingua principale
- JavaScript
- Stelle
- 36
- Fork
- 6
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia con l’hook useStateFromProp in src/amp-react-utils.js alla riga collegata, quindi esamina come amp-carousel espone currentSlide e current-slide. Chiarisci il comportamento desiderato quando un valore viene reimpostato al valore prop esistente; per considerare completato il lavoro, devono essere concordati l’interazione tra property e state e l’ambito dell’implementazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, react
- Ambito
- frontend
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100