[Bug]: Next button throws a runtime error instead of cycling to the first sculpture
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 11.8k
- Forks
- 7.9k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 11
Description
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.
Page
https://react.dev/learn/state-a-components-memory
Details
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open the State: A Component's Memory page and inspect the Sculpture Gallery example, then reproduce the error by clicking Next on sculpture 12 of 12. Trace the example's index update and verify that the gallery returns to the first sculpture without accessing an undefined entry.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- documentation, frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 74/100