Skip to content

Pop nested Router off main Router #296

@thngdude

Description

@thngdude

I'm trying to achieve a Navigator.popToRoute effect as follows:

<Router>

  <Route hideNavBar={true} name="launch" component={connect()(Launch)} initial={true}/>

  <Route name="router1" schema="default" type="push">
    <Router hideNavBar={true}>
      <Route hideNavBar={true} name="aRoute" component={connect()(ARoute)} schema="default" type="reset"/>
      <Route hideNavBar={true} name="bRoute" component={connect()(BRoute)} schema="default" type="push"/>
    </Router>
  </Route>

  <Route name="router2" schema="default" type="push">        
    <Router hideNavBar={true}>
      <Route hideNavBar={true} name="cRoute" component={connect()(CRoute)} schema="default" type="push"/>        
      <Route hideNavBar={true} name="dRoute" component={connect()(DRoute)} schema="default" type="push"/>
    </Router>
  </Route>
</Router>

The flow would be as follows:

  1. Actions.route('router1') from launch to push aRoute

  2. Actions.route('bRoute') from aRoute to push bRoute

  3. Actions.route('router2') from bRoute to push router2, which defaults to cRoute

  4. Actions.route('dRoute') from cRoute to push dRoute

  5. call Actions.currentRouter.parentRoute.parent.pop() to pop router2 and return to router1 (on bRoute)

  6. Once popped back to bRoute, I call Actions.route('router2') again, but I get the following error:

No current router is set

Would appreciate your advice whether this is the correct way to accomplish this popToRoute kind of effect, or if there is a better way to do so.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions