reactjs / reactjs/react.dev

[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.

bug: unconfirmed
Linguagem predominante
JavaScript
Estrelas
11.8k
Forks
7.9k
Merge médio
1d 11h
PRs com merge (30d)
11

Descrição

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

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.

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.

Avaliação

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

Receba novas issues na sua caixa de entrada

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