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

React Navigation - Android didFocus Listener - Issue

$
0
0

I have the following code within a React Native Functional Component. I am using Stack Navigator within a Drawer Navigator.

useEffect(() => {

    const subscription = navigation.addListener(
      'didFocus',
      _payload => {
        console.log('This is called');
        API();
      }
    );

    return () => {
      subscription.remove();
    };
  }, []);

In iOS, When visiting the page for the first time, the addListener callback gets called and prints the console whereas in android, it doesn't execute the callback the first time.

Thereafter, the subsequent calls the listener calls the API and prints console.

Any help on this.


Viewing all articles
Browse latest Browse all 29445

Trending Articles



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