It's All Writing.

Writing makes you happy.

How to navigate between different nested stacks in React Navigation

Environment

  • React Native
  • React Navigation ( react-navigation )
  • lodash

Prerequisites

If we have the following Navigator structure:

ScreenA
ScreenB
ScreenC
ScreenD
  TabScreenA
    StackScreenA
    StackScreenB
  TabScreenB
    StackScreenC
    StackScreenD
  TabScreenC

Then, how do we go from StackScreenD, to StackScreenA?

Solution ( Code )

Now, I'll show you utility function navigaeTo as below.
This function provides you the function which moves to between any screens.

gist.github.com

If you want to move StackScreenD from any screen, you can use navigateTo as below.

navigateTo(['ScreenD', 'TabScreenA', 'StackScreenA']);

Reference

stackoverflow.com