Getting Started with React Navigation, the Navigation Solution for React Native
Spencer Carli
60349

Great article (I am also a student of your new udemy course and it is awesome, so thanks for making it!) I am stuck on something coming from RNRF to react-navigation that you may know how to solve. I had a mobx store, where I would handle actions like submit contact form to server, and on success I would pop the current scene like this:

import { Actions } from 'react-native-router-flux';

contactForm(data){
// Go back
Actions.pop();
}

But how can I accomplish the same thing with react-navigation without passing the navigator instance as a parameter to each store method that would pop or navigate to another route?

Something like this should work, but it does not:

import { NavigationActions } from 'react-navigation';

contactForm(data){
// Go back
NavigationActions.goBack();

// Or Navigate to Route
NavigationActions.navigate('Home');
}

It does not since there is no this.props.navigation accessible in the store, just in the actual component, but I am trying to somehow access the underlying current navigator instance from the store just like in RNRF, and my above syntax that I thought would work.

I am refactoring my entire app, where I use this pattern a lot, and want to make sure I am using the correct approach to programmatically goBack/navigate from the respective store.

Any idea how to solve this?

Show your support

Clapping shows how much you appreciated Moving Gifts’s story.