reactjs / reactjs/react.dev

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

Đang mở Phù hợp với người mới
#8,634 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

bug: unconfirmed
Ngôn ngữ chính
JavaScript
Star
11.8k
Fork
7.9k
Merge trung bình
1 ngày 11 giờ
Pull request đã merge (30 ngày)
11

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Mở trang State: A Component's Memory và kiểm tra ví dụ Sculpture Gallery, sau đó tái hiện lỗi bằng cách nhấp vào Next tại sculpture 12 of 12. Theo dõi việc cập nhật chỉ mục của ví dụ và xác minh rằng thư viện quay lại tác phẩm điêu khắc đầu tiên mà không truy cập vào một mục chưa được định nghĩa.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, react
Lĩnh vực
documentation, frontend
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
74/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.