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.