I am working on a react native app that utilizes a BottomTabNavigator
. The issue I am facing is that when I scroll down a FlatList
in the current tab, then switch to another tab and navigate back again, the scroll position remains at the bottom. How can I automatically scroll to the top of the current tab after navigation?
This is what my code looks like:
navigation.js
import {createBottomTabNavigator} from "react-navigation";
.....................................
name: {
screen: createBottomTabNavigator({
first: { screen: firstNavigation },
second: { screen: secondNavigation },
third: { screen: thirdNavigation }
})
}
I have three tabs named first, second, and third. The issue occurs when navigating between the first and second tabs where the FlatList component is located.
second.js
<View>
<FlatList
data={this.causes}
keyExtractor={this._keyExtractor}
renderItem={this._onPress}
contentContainerStyle={styles.flatListContainer}
/>
</View>