react / react/react-native

Nested Virtualized Lists in opposing directions firing all onViewableItemsChanged

Đang mở
#37,833 9 bình luận 4 reaction 0 người được giao Xem trên GitHub

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

Component: FlatList Issue: Author Provided Repro Newer Patch Available
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

Nested Bidirectional FlatList onViewableItemsChanged Issue

App Image Layout Image

The above images describe the layout where this problem has arisen. Essentially it's a 2D FlatList.

When the Vertical FlatList mounts and the onViewableItemsChanged prop callbacks fire for only the elements on the screen, the expected behavior is working.

However, once the nested FlatLists mount, instead of firing the onViewableItemsChanged callback for only the nested Horizontal FlatList items that are within the visible viewport, it fires for all rendered list items (including those that are out of the viewport). It seems that the correct viewability is determined on horizontal lists, however, the VirtualizedList doesn't check if those horizontal lists are vertically visible.

Below, I've illustrated the expected vs actual behavior with images/emojis

🎇 - Vertical FlatList onViewableItemsChanged callback fires
🔥 - Horizontal FlatList onViewableItemsChanged callback fires

Expected Actual
Untitled-2022-08-26-1424 Untitled-2022-08-26-1424

I provided a minimum setup repo below you can clone. Only changed the App.tsx file to recreate the above steps.

React Native Version

0.71.0

Output of npx react-native info
System:
    OS: macOS 12.6
    CPU: (10) arm64 Apple M1 Max
    Memory: 204.02 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.18.0 - ~/.nvm/versions/node/v16.18.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.18.0/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v16.18.0/bin/npm
    Watchman: Not Found
  Managers:
    CocoaPods: Not Found
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0
    Android SDK:
      API Levels: 29, 30, 31, 32, 33
      Build Tools: 29.0.3, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 33.0.0, 33.0.0
      System Images: android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom_64, android-29 | Google Play ARM 64 v8a, android-29 | Google Play Intel x86 Atom_64, android-31 | Google Play ARM 64 v8a, android-32 | Google APIs ARM 64 v8a, android-32 | Google Play ARM 64 v8a, android-33 | Google Play ARM 64 v8a
      Android NDK: Not Found
  IDEs:
    Android Studio: 2021.3 AI-213.7172.25.2113.9014738
    Xcode: 14.0.1/14A400 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.11 - /Users/vvella/.jenv/shims/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.1.0 => 18.1.0
    react-native: 0.70.4 => 0.71.0
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
Steps to reproduce
  1. Create a vertical FlatList that contains a 2D data array with a length long enough to make the list run off of your screen and require scrolling
  2. Create another FlatList (horizontal) to be rendered in the renderItem prop of the parent FlatList
  3. Add an onViewableItemsChanged to the nested (horizontal) FlatList
  4. Observe that all items rendered (regardless of vertical viewability) fire their onViewableItemsChanged callback
Snack, code example, screenshot, or link to a repository

Taken from the tester app
See that InnerViewable shows "56,57,58"
All of which are horizontally viewable but not vertically shown in the viewport

Snack: https://snack.expo.dev/@vincentvella/great-almond
Repo: https://github.com/vincentvella/bidirectional-virtualized-list-issue

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 App.tsx trong bản tái hiện được liên kết và chạy Snack hoặc clone repository để tái hiện các FlatLists dọc và ngang lồng nhau. Sau đó, theo dõi hành vi viewability của React Native FlatList/VirtualizedList liên quan đến các danh sách lồng nhau. Hoàn thành khi callback bên trong chỉ báo cáo các mục hiển thị trong cả danh sách ngang và viewport dọc của phần tử cha.

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-dev
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
45/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.