react / react/react-native

FlatList re-mount all the row when using columns

Open
#45,895 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Component: FlatList Issue: Author Provided Repro Newer Patch Available
Dominant language
C++
Stars
127k
Forks
25.3k
Avg merge
1d 23h
Merged PRs (30d)
4

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Snack reproducer and the FlatList configuration using numColumns greater than one. Reproduce an insertion and removal while observing row mounts on Android and iOS. Done means the affected row's existing items are not re-mounted during these updates, with the behavior verified against the reported React Native version.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react, react-native
Domain
frontend, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.