react / react/react-native

FlatList re-mount all the row when using columns

Offen
#45,895 4 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

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

Beschreibung

Description

Regardless of the use of optimization techniques, such as React.memo or useCallback, when a FlatList with columns (numColumns > 1) is created and an element is added or removed from the list, this causes all components of the row where the element was added or removed to be re-mounted. This is easily noticeable if entry animations are used (but it has other serious repercussions). I'm currently stuck in development on this issue (and switching to unsare scroll view would make the app unusable). There are many similar issues by now, all closed without any discussion or solution, and since it has been years now I think it is time to take the problem into consideration.

Steps to reproduce
  1. configure a Flatlist with numColumns > 1 2) add dynamically a new item or remove an item 3) all the items of the row addicted are re-mounted
React Native Version

0.74.3

Affected Platforms

Runtime - Android, Runtime - iOS

Output of npx react-native info
System:
  OS: macOS 14.5
  CPU: (8) arm64 Apple M2
  Memory: 127.25 MB / 8.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.4.1
    path: /opt/homebrew/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.8.2
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2024.07.01.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/niccolocaselli/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK:
    Android NDK: 22.1.7171670
IDEs:
  Android Studio: 2023.2 AI-232.10300.40.2321.11567975
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.11
    path: /usr/bin/javac
  Ruby:
    version: 2.7.6
    path: /Users/niccolocaselli/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.3
    wanted: 0.74.3
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false
Stacktrace or Logs
no crash
Reproducer

https://snack.expo.dev/@niccolocase/0aa680

Screenshots and Videos

https://github.com/user-attachments/assets/891e73d0-d77f-4b3e-8beb-5a1fe60c5a82

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 verlinkten Snack-Reproduzierer und der FlatList-Konfiguration mit einem numColumns-Wert größer als eins. Reproduziere eine Einfügung und eine Entfernung und beobachte dabei die Row-Mounts auf Android und iOS. Als abgeschlossen gilt dies, wenn die vorhandenen Elemente der betroffenen Zeile während dieser Aktualisierungen nicht erneut gemountet werden und das Verhalten anhand der gemeldeten React Native-Version verifiziert wurde.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

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

Neue Issues direkt in Ihr Postfach

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