ampproject / ampproject/amp-react-prototype

Property change states

Offen
#47 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
TBD
Vorherrschende Sprache
JavaScript
Sterne
36
Forks
6
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit dem useStateFromProp hook in src/amp-react-utils.js an der verlinkten Zeile und untersuche anschließend, wie amp-carousel currentSlide und current-slide bereitstellt. Kläre das gewünschte Verhalten, wenn ein Wert auf seinen bestehenden prop-Wert zurückgesetzt wird; für den Abschluss müssen eine abgestimmte Property/State-Interaktion und ein Implementierungsumfang feststehen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, react
Bereich
frontend
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

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