react / react/react-native

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

Offen
#46,588 2 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Component: SectionList Issue: Author Provided Repro
Vorherrschende Sprache
C++
Sterne
127k
Forks
25.3k
Ø Merge
1 T. 23 Std.
Gemergte PRs (30 T.)
4

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem verknüpften Expo Snack und reproduziere den Fehler auf Android oder iOS, indem du die SectionList prop onViewableItemsChanged ein- und ausschaltest. Verfolge, wie die Sichtbarkeitsverfolgung den section keyExtractor aufruft, und überprüfe, dass ihm unabhängig davon, ob diese prop gesetzt ist oder nicht, konsistent nur Elemente innerhalb jedes Abschnitts übergeben werden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
react-native
Bereich
mobile
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.