<VirtualizedList renderScrollComponent> should preserve child elements
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
It's extremely confusing that this works:
<VirtualizedList
renderScrollComponent={props =>
<ScrollView {...props} />
}
// ...
/>
but this doesn't:
<VirtualizedList
renderScrollComponent={props =>
<View>
<ScrollView {...props} />
</View>
}
// ...
/>
The reason appears to be that the third cells argument to cloneElement call here (which in this case would be passed a <View>) overrides the children of that top-level element. So the ScrollView inside gets lost.
What I believe should happen instead is that scrollProps should include children: cells. Then it's up to your renderScrollComponent function to decide what to do with it.
That would be a breaking change but it seems a lot more in line with how React components are supposed to work? It's bad that wrapping a top-level component completely breaks the logic. (I spent an hour debugging this because I couldn't believe a built-in RN component would do this :). It's possible that I badly misunderstood something, so apologies if that's the case.
React Native Version
0.72.5
Output of npx react-native info
info Fetching system and libraries information...
System:
OS: macOS 13.2.1
CPU: (10) arm64 Apple M1 Max
Memory: 12.29 GB / 64.00 GB
Shell:
version: 5.8.1
path: /bin/zsh
Binaries:
Node:
version: 18.17.1
path: /usr/local/bin/node
Yarn:
version: 1.22.19
path: /usr/local/bin/yarn
npm:
version: 9.6.7
path: /usr/local/bin/npm
Watchman:
version: 2023.01.30.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.11.3
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 22.4
- iOS 16.4
- macOS 13.3
- tvOS 16.4
- watchOS 9.4
Android SDK: Not Found
IDEs:
Android Studio: 2022.1 AI-221.6008.13.2211.9514443
Xcode:
version: 14.3.1/14E300c
path: /usr/bin/xcodebuild
Languages:
Java:
version: javac 18
path: /usr/bin/javac
Ruby:
version: 2.7.6
path: /Users/dan/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.72.5
wanted: 0.72.5
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false
Steps to reproduce
see earlier
Snack, screenshot, or link to a repository
this is about API design
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 dans packages/virtualized-lists/Lists/VirtualizedList.js, autour de la construction de scrollProps et de l'appel à cloneElement référencés dans l'issue. Reproduisez les exemples de renderScrollComponent, puis déterminez si la conservation de l'enfant enveloppé peut être couverte par un test de régression approprié et si le comportement proposé de children est acceptable en tant que changement d'API.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript, react-native
- Domaine
- mobile
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100