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

Aberta Para iniciantes
#8,634 3 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
74/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
javascript, react

Direção de pesquisa

Abra a página State: A Component's Memory e inspecione o exemplo Sculpture Gallery; em seguida, reproduza o erro clicando em Next em sculpture 12 of 12. Acompanhe a atualização do índice do exemplo e verifique se a galeria retorna à primeira escultura sem acessar uma entrada indefinida.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

bug: unconfirmed
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

Linguagem predominante
JavaScript
Estrelas
11.8k
Forks
7.9k
Merge médio
16h 6min
PRs com merge (30d)
7

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de reactjs/react.dev

Todas as issues de reactjs/react.dev

Issues semelhantes

Mais issues de JavaScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.