Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

How to show alert popup only inside specific screen using react native?

$
0
0

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 },        );}

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>