I have an app that uses this code: Linking.openURL('google.navigation:q='+latitude+'+'+longitude) to exit to google maps in my React Native Expo app.
With android (and iOS) you can use the phone's back button to return to your previous app. I am wondering how I can call a function when my app comes back into view.
I have some GPS data in my app that I would like to reupdate my data after they move to a location as soon as they return to my app. I found this....
componentWillMount() {
const { navigation } = this.props;
this.focusListener = navigation.addListener('didFocus', () => {
// The screen is focused
// Call any action
});
}
But it doesn't seem to call when I return from maps..,
Is this close or am I doing it completely wrong?
Thanks
componentWillMountexecutes only once in the component life cycle. You probably needcomponentDidUpadtemethod (condition: your component gets updated when you come back to the view).