3

In my current scene stack, I have 3 scenes A,B and C. Going back and forth from A to B to C works fine. But I couldn't navigate back to scene A directly from scene C. Is this possible? My current code looks like this:

<Scene key="root">
  <Scene key="aKey" component={A} />
  <Scene key="bKey" component={B} />
  <Scene key="cKey" component={C} />
</Scene>

So far, I've tried adding this code in my C component:

Actions.pop

But it only navigates back to previous scene(i.e. B component) and I am trying to navigate back directly to root scene (i.e. A component)

Singh
  • 1,887
  • 3
  • 18
  • 29

2 Answers2

5

You are using Actions.pop() ; That means it will navigate to back screen . Use

Actions.reset('akey')

this will navigate to scene A directly.

Singh
  • 1,887
  • 3
  • 18
  • 29
  • I am getting error for this, and the error is "There is no route defined for key KEY, must be one of 'root','app'" – droidev Dec 04 '19 at 10:01
2

As Rahul mentioned, one way of doing it is

Actions.reset('aKey')

The other approach that I figured out is

Actions.popTo('aKey')
Singh
  • 1,887
  • 3
  • 18
  • 29