I want to track the time when a user navigates through the screen and when it leaves the screen. I also want to set state and then send those data to API.
const Stack = createStackNavigator();
const Tab = createMaterialTopTabNavigator();
export default function BootcampWeeksScreen(props){
const { navigation } = props;
const pathway_id=navigation.getParam('pathway_id');
return (
<NavigationContainer>
<Tab.Navigator tabBarOptions={{ scrollEnabled: true }}>
<Tab.Screen name="Course" component={Courses} initialParams={{pathway_id:pathway_id}} />
<Tab.Screen name="Roadmap" component={Roadmap} />
</Tab.Navigator>
</NavigationContainer>
);
}
When a user navigates to the Course
screen I want to track that time when the user leaves the screen.
How can I do this?