Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6213

typescript expo '_this.flatListRef = _ref4' undefined is not an object

$
0
0

Trying to set up scrollToIndex on a flatlist with typescript on expo but getting an error I don't really understand.I was following the example snack https://snack.expo.io/@s2gt05/flatlist-scrolltoindex-practical-example.-

Below is the flatlist that I have now

<FlatList        data={data}        ref={(ref) => {if (ref) {this.flatListRef = ref }}}        renderItem={({ item, index }) => (<TouchableOpacity onPress={() => onSelect(index)}><Text>{item.title}</Text></TouchableOpacity>        )}      />    const categorySelector = (index) => {      if (this.flatListRef) {        this.flatListRef.scrollToIndex({index: index})      }    }

Viewing all articles
Browse latest Browse all 6213

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>