react / react/react-native

Adding onViewableItemsChanged to SectionList changes the items passed to each section's keyExtractor

Đang mở
#46,588 2 bình luận 1 reaction 0 người được giao Xem trên GitHub

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

Component: SectionList Issue: Author Provided Repro
Ngôn ngữ chính
C++
Star
127k
Fork
25.3k
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
4

Mô tả

Description

We wrote a SectionList component where each section defines it's own keyExtractor. One of the sections uses a key from a nested object in each item in the section. It broke when we wanted to add visibility tracking to the section list, and it seems like the section objects are being run through the keyExtractor but only when onViewableItemsChanged prop is provided.

I expect that only items within each section should be run through the section's keyExtractor function, and that the behavior is consistent regardless of what props are provided.

Steps to reproduce
  1. Open expo snack linked below
  2. Run it on android or iOS device and observe it works
  3. Uncomment the onViewableItemsChanged line from the SectionList and observe the break
React Native Version

0.75.3

Affected Platforms

Runtime - Android, Runtime - iOS

Output of npx react-native info
See expo snack for reproduction
Stacktrace or Logs
Cannot read property 'id' of undefined
Reproducer

https://snack.expo.dev/V1Ad0VTld860Zdt8n-qb7

Screenshots and Videos
Screenshot 2024-09-20 at 5 07 04 PM

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

Bắt đầu với Expo Snack được liên kết và tái hiện lỗi trên Android hoặc iOS bằng cách bật tắt prop onViewableItemsChanged của SectionList. Theo dõi cách việc theo dõi khả năng hiển thị gọi section keyExtractor và xác minh rằng chỉ các item trong từng section được truyền cho nó một cách nhất quán, dù có hay không có prop đó.

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

Đánh giá

Công nghệ
react-native
Lĩnh vực
mobile
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
42/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.