When you open the screen for the first time, it runs the "IdidMount" to mount the screen, if you continue browsing, it will no longer run.
You can change this behavior by checking if the screen has received new props, or by adding a "Systener" when assembling the screen for the first time, so that whenever it receives the focus some programming is executed. Here is an example:
import React, { Component } from 'react';
import { View } from 'react-native';
import { withNavigation } from 'react-navigation';
class TabScreen extends Component {
componentDidMount() {
const { navigation } = this.props;
this.focusListener = navigation.addListener('didFocus', () => {
// Executar alguma ação
});
}
componentWillUnmount() {
// Remove o listener ao desmontar
this.focusListener.remove();
}
render() {
return <View />;
}
}
export default withNavigation(TabScreen);
Here is more information:
https://reactnavigation.org/docs/en/function-after-focusing-screen.html