reactjs / reactjs/react.dev

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

Aperta Adatta ai principianti
#8,634 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug: unconfirmed
Lingua principale
JavaScript
Stelle
11.8k
Fork
7.9k
Merge medio
1g 11h
PR unite (30g)
11

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Apri la pagina State: A Component's Memory e ispeziona l'esempio Sculpture Gallery, quindi riproduci l'errore facendo clic su Next su sculpture 12 of 12. Traccia l'aggiornamento dell'indice dell'esempio e verifica che la galleria torni alla prima scultura senza accedere a una voce non definita.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, react
Ambito
documentation, frontend
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Attiva
Chiarezza
Abbastanza chiara
Idoneità per principianti
74/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.