[Android] - Can't access ShadowNode in FlatList with horizontal prop
Personne n'a encore pris cette issue.
- Langage dominant
- C++
- Étoiles
- 127k
- Forks
- 25.3k
- Merge moyen
- 1 j 23 h
- PR mergées (30 j)
- 4
Description
Description
I've found a discrepancy between Android and iOS platforms.
When the horizontal prop is set, the ref returned during unmount has a nullable NativeState property which breaks ShadowNode cleanup required by Unistyles.
How I access the NativeState for FlatList components:
ref?.getScrollResponder?.()?.getNativeScrollRef?.()?.__internalInstanceHandle?.stateNode?.node
and then in C++:
ShadowNode::Shared shadowNode = shadowNodeFromValue(rt, args[0]); // args[0] is jsi::Value with NativeState
Desired behaviour:
I should be able to access ShadowNode during cleanup to perform own cleanups as in any other component or without horizontal prop.
Steps to reproduce
- Install the provided repro
- Run the app on Android and open the debugger to view
console.logoutput - You should see two logs:
Mount NativeState: ✅ - Tap the
Reloadbutton - Notice that
NativeStateis no longer present:Unmount NativeState: ❌ - Run the app on iOS and open the debugger to view
console.logoutput - Verify that
NativeStateis present in both the mount and unmount phases - Comment out the
horizontalprop - Verify that
NativeStateis present in both the mount and unmount phases on both iOS and Android
React Native Version
0.79.2
Affected Platforms
Runtime - Android
Areas
Fabric - The New Renderer
Output of npx @react-native-community/cli info
System:
OS: macOS 15.3.2
CPU: (12) arm64 Apple M3 Pro
Memory: 2.15 GB / 36.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 23.5.0
path: /opt/homebrew/bin/node
Yarn:
version: 1.22.22
path: /opt/homebrew/bin/yarn
npm:
version: 10.9.2
path: /opt/homebrew/bin/npm
Watchman:
version: 2024.12.02.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.16.2
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.4
- iOS 18.4
- macOS 15.4
- tvOS 18.4
- visionOS 2.4
- watchOS 11.4
Android SDK:
API Levels:
- "23"
- "28"
- "29"
- "30"
- "33"
- "34"
- "35"
Build Tools:
- 30.0.3
- 34.0.0
- 35.0.0
System Images:
- android-23 | ARM 64 v8a
- android-24 | Google APIs ARM 64 v8a
- android-26 | Google APIs ARM 64 v8a
- android-28 | ARM 64 v8a
- android-29 | ARM 64 v8a
- android-30 | ARM 64 v8a
- android-30 | Google APIs ARM 64 v8a
- android-34 | Android TV ARM 64 v8a
- android-34 | ARM 64 v8a
- android-34 | Google APIs ARM 64 v8a
- android-35 | Google APIs ARM 64 v8a
- android-35 | Google Play ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2024.3 AI-243.25659.59.2432.13404313
Xcode:
version: 16.3/16E140
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.11
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli":
installed: 18.0.0
wanted: 18.0.0
react:
installed: 19.0.0
wanted: 19.0.0
react-native:
installed: 0.79.2
wanted: 0.79.2
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
Stacktrace or Logs
No crash
MANDATORY Reproducer
https://github.com/jpudysz/react-native-horizontal-flatlist-repro
Screenshots and Videos
Android + horizontal prop
Android + no horizontal prop
iOS + horizontal prop
iOS + no horizontal prop
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par le reproducer obligatoire et comparez les logs Android et iOS de FlatList avec et sans le prop horizontal. Suivez le chemin de nettoyage de Fabric ShadowNode autour de NativeState et de l’implémentation Android, en utilisant la configuration React Native 0.79.2 signalée. Le travail est terminé lorsque NativeState reste disponible pendant le nettoyage de l’unmount Android pour FlatList horizontal, comme dans les autres cas.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- android, cpp, react-native
- Domaine
- mobile-dev
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100