st0ffern / react-native-optimized-flatlist

Optimization for complex and slow React Native FlatLists
MIT License
259 stars 47 forks source link

FlatlistRef.ScrollToIndex is not a function #29

Closed NikiTsv closed 6 years ago

NikiTsv commented 6 years ago

I am not able to use scrollToIndex. Is that intended? ref={(ref) => { this.flatListRef = ref; }}

st0ffern commented 6 years ago

It should work, but call the function directly instead of ref.

Sangrene commented 6 years ago

Hey @stoffern , how do you call this function "directly" without a ref to the proper component then ?

wasedaigo commented 5 years ago

yeah , what is the usage?

yannoudou commented 5 years ago

i think a find a way to deal with that issue.

  1. pass that ref={(ref) => { this.flatListRef = ref; }} to OptimizedFlatList Component

  2. create in OptimizedFlatList a scrollToIndex function and bind it in the constructor: like this.scrollToIndex=this.scrollToIndex.bind(this).

  3. your scrollToIndex function could look like: scrollToIndex(){ // what ever you want to achieve }

  4. you can call now this.flatListRef.scrollToIndex(index) and the scrollToIndex function you have created in OptimizedFlatList, will trigger