sandeep
sandeep

Reputation: 163

scrolltolocation not working outside of initialNumToRender props window in Sectionlist untill I manually scroll

I am using sectionlist for showing data in react native. I have large data with a section list. Here We use scrolltolocation for scrolling to the specific section but it is not working until I render to that section using manual scroll

My Code:

<SectionList
  sections={this.props.fooddata}
  ref={(s) => (this.sectionList = s)}
  //onScroll={this.handleScroll}
  stickySectionHeadersEnabled={true}
  onViewableItemsChanged={this.props.onCheckViewableItems}
  viewabilityConfig={{
      itemVisiblePercentThreshold: 50 //means if 50% of the item is visible
  }}

  removeClippedSubviews={false}

  maxToRenderPerBatch={6}


  scrollEnabled={true}



  onScrollToIndexFailed={info => {
      const wait = new Promise(resolve => setTimeout(resolve, 500));
      wait.then(() => {

          //flatList.current?.scrollToIndex({ index: info.index, animated: false });
      });
  }}


  initialNumToRender={4}
  windowSize={5}

  ListFooterComponent={this.ItemSeprator}

  style={{ width: this.windowwidth,top:this.props.searchclicked?135:(this.props.nonveg || this.props.veg)?200:117,bottom:0,position:'absolute'}}
  // keyExtractor={(item, index) => index}
  keyExtractor={this.keyExtractor}

  renderSectionHeader={({ section,index }) => this.createSection(section,index)}
  // renderItem={(item)=>this.jackRecommned(item)}  //{({ item, index }) => this.renderItem(item, index)}

  renderItem={this.renderItem.bind(this)}
  renderFooter={this.footer}


/>

Upvotes: 5

Views: 586

Answers (0)

Related Questions