reactjs / reactjs/react.dev

[Bug]: Next button throws a runtime error instead of cycling to the first sculpture

Offen Anfängerfreundlich
#8,634 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug: unconfirmed
Vorherrschende Sprache
JavaScript
Sterne
11.8k
Forks
7.9k
Ø Merge
1 T. 11 Std.
Gemergte PRs (30 T.)
11

Beschreibung

Summary

On the State: A Component's Memory page, the Sculpture Gallery example allows users to navigate through sculptures using the Next button. The gallery works correctly while navigating through valid entries, but when the user clicks Next on the final sculpture (12 of 12), the application does not cycle back to the first sculpture.

Instead, the index exceeds the sculpture list bounds, making sculpture undefined and causing the runtime error:

App.js: can't access property "name", sculpture is undefined

Expected: The gallery should wrap around from the last sculpture to the first sculpture when Next is clicked.

Actual: The application throws a runtime error because it attempts to access properties such as sculpture.name on an undefined object.

Affected screen: React.dev → Learn React → Adding Interactivity → State: A Component's Memory → Sculpture Gallery example.

Image Image
Page

https://react.dev/learn/state-a-components-memory

Details

No response

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Öffne die Seite State: A Component's Memory und untersuche das Beispiel Sculpture Gallery. Reproduziere dann den Fehler, indem du bei sculpture 12 of 12 auf Next klickst. Verfolge die Indexaktualisierung des Beispiels und überprüfe, dass die Galerie zur ersten Skulptur zurückkehrt, ohne auf einen undefinierten Eintrag zuzugreifen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, react
Bereich
documentation, frontend
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Aktiv
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
74/100

Neue Issues direkt in Ihr Postfach

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