react / react/react-native

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

オープン
#46,588 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Component: SectionList Issue: Author Provided Repro
主要言語
C++
スター
127k
フォーク
25.3k
平均マージ
1日 23時間
マージ済み PR(30日)
4

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

リンクされた Expo Snack から始め、SectionList の onViewableItemsChanged prop を切り替えて Android または iOS で失敗を再現します。可視性の追跡が section keyExtractor を呼び出す方法を追跡し、その prop の有無にかかわらず、各セクション内のアイテムだけが一貫して渡されることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
react-native
領域
mobile
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。