In My case, I have implemented alert popup within a function and the function will call from componentDidMount()
. Now the problem is the alert implemented inside the home screen but I am getting alert in other screen also. I want to show alert only when I am in home screen.
If user in other screen alert should not show.
My Code: (Home.tsx)
componentDidMount = async () => { this.showAlert();}async showAlert() {Alert.alert(‘Hello’, [ { text: "ok", onPress: () => { }, style: 'cancel', }, { text: "goodbye", onPress: () => { this.props.navigation.navigate(‘details); }, }, ], { cancelable: false }, );}