I'm trying to set up scroll to index on a flatList based a variable with typescript.Examples I've found are with react and doesn't seem to work with what I have at the moment.
My project actually has two flatlists and I want the scroll to dynamically move based on what is selected.Below is a simplified example of what I have, just want an idea on how to make it work first. But obviously not working.
<FlatList //tried this, but don't know how to pass the actual index ref={(ref) => { ref?.scrollToIndex({index: 0}) }} renderItem={({ item }) => { return (<TouchableOpacity onPress={() => onSelect(item, index)}> <View></View></TouchableOpacity> )}} />
onSelect function, dont know how to pass the index back to the flatList
const onSelect = (item, index) => { //scrollToIndex(index)?}
Some guidance would be appriciated :)