-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
SectionList renders all items at once. #48258
Comments
@shubhamguptadream11 |
I'm having the same problem |
It seems like both If you want to avoid that you can use |
@ponikar In your example I migrated to the |
Thanks for the confirmation. @vovka-s |
In my case, I was actually seeing the sectionlist & flatlist rendering everything in the data set, even things way outside the window range. I started from scratch, and copied code in piece by piece to identify what was causing it. Turns out, it was a "gap" style applied to the list items It seems that if you mess with the size or spacing of flatlist outside of it's allowed props, it loses track of where it is in the list, and decides to render the whole thing. Replacing the "gap" style with a spacer component fixed the problem. Would be nice if flatlist/sectionList notified you that it's having difficult keeping track of where it is in the list |
Description
I found out section list invokes
renderItem
method for all the items even if there are not visible in the screen.Here's the expo snack link: https://snack.expo.dev/7cjOb_kzYa8_8gcuW9i9s
If anyone can help understand why is it happening?
This is the basic code snippet
Here's the output logs.
Steps to reproduce
Create a basic react native project with or without framework. Copy and paste the above code or just run the expo snack.
React Native Version
0.76.5
Affected Platforms
Runtime - iOS
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://snack.expo.dev/7cjOb_kzYa8_8gcuW9i9s
Screenshots and Videos
No response
The text was updated successfully, but these errors were encountered: