question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sectionlist not loading all item at once

See original GitHub issue

Description

I am using section list with initialNumToRender = All data length in all section, but it not rendering all item at once

sometime it render half or some time it render more and showing extra scroll

need help of this

Version

0.64

Output of react-native info

OS: macOS 11.5.2 CPU: (8) x64 Intel® Core™ i5-8279U CPU @ 2.40GHz Memory: 17.10 MB / 8.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 12.22.6 - /usr/local/bin/node Yarn: Not Found npm: 6.14.15 - /usr/local/bin/npm Watchman: Not Found Managers: CocoaPods: 1.11.2 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4 Android SDK: Not Found IDEs: Android Studio: 3.5 AI-191.8026.42.35.5900203 Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild Languages: Java: 11.0.12 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: 0.64.0 => 0.64.0 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

It replicate with any section list with more items, In my case case total 20 section are there and total 142 items are there

Snack, code example, screenshot, or link to a repository

<SectionList sections={this.props.OrderData} ref={(s) => (this.sectionList = s)} stickySectionHeadersEnabled={true} removeClippedSubviews={false}

                    //maxToRenderPerBatch={20}
                   
                    
                    scrollEnabled={true}
                   // onScrollToIndexFailed={this.scrollToIndexFailed.bind(this)}
                  
                  
                    onScrollToIndexFailed={info => {
                        const wait = new Promise(resolve => setTimeout(resolve, 500));
                        wait.then(() => {
                           // alert(JSON.stringify(info))
                          flatList.current?.scrollToIndex({ index: info.index, animated: false });
                        });
                      }}

                      initialNumToRender={this.props.countofData}

                   // getItemLayout={this.getItemLayout.bind(this)}
                    scrollEventThrottle={1000}
                   // ListFooterComponent={this.ItemSeprator}
                      
                    onEndReached={this.props.handleloadMore}
                    onEndReachedThreshold={0.01}
                    style={{ flex:0, top: this.screenHeight <= 480 ? 230 : 255, bottom: 5, width: '100%',position:'absolute' }}
                    keyExtractor={(item, index) => index}

                    renderSectionHeader={({ section }) => ()}
                  renderItem={this._renderItem}
                  />

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

3reactions
Ray-Frostcommented, Mar 23, 2022

@anastely I temporarily skipped it by setting initialNumToRender, perhaps you could try it.

1reaction
kptpcommented, Apr 14, 2022

I had the same issue where sometimes a section list would render only the first 10 items (section headers + footers included). Eventually I found out that this happened because react native’s InteractionManager.runAfterInteractions was not triggering. This, in my case, was caused by @react-navigation/drawer leaking interaction handles. This was fixed in PR: https://github.com/react-navigation/react-navigation/pull/10413 so upgrading @react-navigation/drawer to 6.3.3 fixed this issue for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Some items do not display in SectionList until scroll trigger
If I remember correctly, SectionList and Flatlist do not render all the items at once due to performance. They lazy load them instead....
Read more >
Displaying a List in React Native: Map Method or FlatList ...
In this article, I'll walk you through using two methods of listing data in a React Native app: displaying the list with map...
Read more >
Using List Views - React Native
Unlike the more generic ScrollView , the FlatList only renders elements that are currently showing on the screen, not all the elements at...
Read more >
SectionList · React Native
Internal state is not preserved when content scrolls out of the render window. Make sure all your data is captured in the item...
Read more >
React native SectionList Component - GeeksforGeeks
scrollToLocation(): It is used to scroll to the item at any specified sectionIndex and itemIndex. Installation: Here we will use the Expo CLI ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found