react-nativereact-native-navigationwix-react-native-navigation

How to navigate to a same screen on stack in react native


I have a stack in react-native-navigation. I want to navigate to a screen that is in the stack before. but when I use Navigation.push command nothing happened and the screen does not change. How to implement this on react-native??

for exmaple my stakc is: [the part in the () does not navigate]

Main -> Map -> Stores (-> Map)

Note: I can't pop the screen to navigate to map. Because when I use the button that I Navigate with it, maybe the Map Screen doesn't in the stack. In the other word, some times I navigate from Main to Map and then to Stores, and some times I navigate to Stores from Main directly. and my button that is saying about to navigate to Stores screen in Map screen.


Solution

  • I finally found the solution.

    Navigation.push or Navigation.pop is a promise that is made error when there is impossible to run command for any reason.

    I use it and when Navigation.push made error in catch clause, I pop the screen.

    For example:

    Navigation.push('Map', {
      component: {
        id: 'Stroes',
        name: 'Stroes',
        options: {},
        passProps: {},
      },
    }).catch(e => {
      Navigation.pop('Stroes');
    });