Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Last FlatList item component re-mounted when adding new elements at the beginning of the list #44756

Open
exploIF opened this issue Jun 3, 2024 · 6 comments
Labels
Component: FlatList Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project.

Comments

@exploIF
Copy link

exploIF commented Jun 3, 2024

Description

Each time a new component is added at the beginning or in the middle of the list, the last component (the one that was added first) re-mounts. I've noticed that when a new component is added to the list, a spacer component is created and it always replaces last component in that list, even if new components are added at the beginning or in the middle of the list. This makes last item to completely re-mount. This problem only occurs when the initialNumToRender is exceeded.

Steps to reproduce

  1. Run repro from linked snack.
  2. Press add button multiple times (at least 4).
  3. You will see in the terminal that after reaching initialNumToRender last item is unmounted.

React Native Version

0.74.1

Affected Platforms

Runtime - Android, Runtime - iOS

Output of npx react-native info

System:
  OS: macOS 14.4.1
  CPU: (11) arm64 Apple M3 Pro
  Memory: 110.58 MB / 18.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 21.7.3
    path: /opt/homebrew/bin/node
  Yarn:
    version: 4.1.1
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.5.0
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2024.04.08.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /opt/homebrew/bin/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:
    API Levels:
      - "31"
      - "34"
    Build Tools:
      - 30.0.3
      - 33.0.1
      - 34.0.0
    System Images:
      - android-34 | Google APIs ARM 64 v8a
      - android-TiramisuPrivacySandbox | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2023.2 AI-232.10300.40.2321.11668458
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.10
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.0
    wanted: 0.74.0
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

-

Reproducer

https://snack.expo.dev/@exploifswm/flat-list-item-re-mount

Screenshots and Videos

No response

@deepanshushuklad11
Copy link
Contributor

@cortinico Any update on this ?

@cortinico
Copy link
Contributor

@cortinico Any update on this ?

Nope no updates. We're hyperfocused on fixing New Architecture bugs at the moment, so unless this is a New Architecture specific bug, we won't be able to fix it in the immediate future

@deepanshushuklad11
Copy link
Contributor

@cortinico This is happening in both new arch and old .

@cortinico
Copy link
Contributor

@cortinico This is happening in both new arch and old .

Yup but is not New Architecture specific (i.e. is not a regression)

@deepanshushuklad11
Copy link
Contributor

@cortinico anyways i started debugging.
I think the issue is here

newProps.maintainVisibleContentPosition != null &&

This check is not needed in my opinion , but currently i am not sure of its impact .
If you could help me guiding in right direction that would be of great help

@deepanshushuklad11
Copy link
Contributor

@exploIF can you try this out .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: FlatList Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project.
Projects
None yet
Development

No branches or pull requests

3 participants