I have a scrollview which has a flatlist nested inside of it, so now I want to scroll to a certain position of the scrollview on button press, how can I achieve this? Here is my code:
<ScrollView
ref={verticalRef}
>
{
data.map( item => (
<View>
<Text style={styles.title}>{item.title}</Text>
<View >
<FlatList
data={item.data}
numColumns={2}
renderItem={thitem}
/>
</View>
</View>
))
}
</ScrollView>
Here is the handler for the scroll: const scrollToActiveIndex = (index) => { setActiveIndex(index) verticalRef.current?.scrollTo({ x: width * index, animated: true }) }
I have also attached a screenshot of my app. Thanksenter image description here