Invariant violation: calling a pop route for a route that doesn't exist

I am using NavigatorIOS, and when the props that I pass to the initial re-route, I try to update them by dropping the component you find below with the new updated props in "componentWillReceiveProps".

    componentWillReceiveProps: function(nextProps) {
      this.refs.navigator.resetTo({
                    title: 'Home',
                    component: search,
                    backButtonTitle: 'Back',
                    passProps: {
                      api: nextProps.api,
                      slug: nextProps.slug
                   }
      });
    }

      

I'm sure I'm not getting the route right, but to be honest, I haven't found any helpful resource regarding this issue.

Replace () does the job of updating the props, but I also want it to popToTop (). Replace and ResetTo take the route object, so I don't understand why replace () works and resetTo () is giving me this error.

This is my NavigatorIOS:

      <NavigatorIOS
            ref='navigator'
            initialRoute={
            {
              title: 'Home',
              component: search,
              backButtonTitle: 'Back',
                    passProps: {
                        api: this.props.api,
                        slug: this.props.slug
                     }

             }
           }
    />

      

enter image description here

+3


source to share


2 answers


If you declare something like:

var routes = this.refs.navigator.getCurrentRoutes();

      



Then you can go to the next route:

this.refs.navigator.popToRoute(routes[1]);

      

+1


source


Try using more tame, but less limited React.Navigator

and …navigator.immediatelyResetRouteStack()

.



See the Navigator docs https://facebook.github.io/react-native/docs/navigator.html

0


source







All Articles