描述
每次在列表开头或中间添加新组件时,最后一个组件(最早添加的组件)都会重新挂载。我注意到当向列表中添加新组件时,会创建一个间距组件,它总是替换该列表中的最后一个组件,即使是在列表的开头或中间添加了新组件。这使得最后一个项目完全重新挂载。这个问题只在 initialNumToRender
被超过时发生。
重现步骤
- 从链接的Snack中运行重现。
- 多次按下
add
按钮(至少4次)。 - 在终端中,您会看到在达到
initialNumToRender
后,最后一个项目被卸载。
React Native 版本
0.74.1
受影响的平台
运行时 - Android,运行时 - iOS
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
堆栈跟踪或日志
-
可复现问题
https://snack.expo.dev/@exploifswm/flat-list-item-re-mount
截图和视频
- 无响应*
6条答案
按热度按时间axzmvihb1#
@cortinico 对此有任何更新吗?
xtupzzrd2#
@cortinico 有任何更新吗?
没有更新。我们目前专注于修复新架构的bug,所以除非这是新架构特定的bug,否则我们无法立即修复它。
i5desfxk3#
这是在新旧arch中都发生的事情。
knsnq2tg4#
这是在新架构和旧架构中都发生的事情。
是的,但这并不是新架构特有的问题(即不是回归)。
lfapxunr5#
@cortinico anyways i started debugging.
I think the issue is here
react-native/packages/virtualized-lists/Lists/VirtualizedList.js
Line 716 in 8c8c77b
| | 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
qvtsj1bj6#
请尝试这个。