Open jordanmkoncz opened 7 years ago
yeah, I am facing same issue
Anyone been able to look into this? I'm now running into another problem because of this issue, where I need to use currentNavigatorUID
to determine the current screen name for analytics purposes, but again can't do this reliably since currentNavigatorUID
becomes incorrect.
bump :/
I'm having an issue where navigating through my navigation hierarchy leads to
currentNavigatorUID
in my Redux store becoming incorrect and inconsistent with what the user is actually seeing on their screen.In my hierarchy, at the top level is a StackNavigation (
navigatorUID="rootStackNavigation"
). Below this is two possible children, TabNavigation (navigatorUID="tabNavigationA"
) and TabNavigation (navigatorUID="tabNavigationB"
). BelowtabNavigationA
is a StackNavigation (navigatorUID="stackNavigationChildA"
). BelowtabNavigationB
is a StackNavigation (navigatorUID="stackNavigationChildB"
).On load, the initial hierarchy is
rootStackNavigation
->tabNavigationA
->stackNavigationChildA
. From there the user can navigate totabNavigationB
, which happens by callingnavigation.getNavigator('rootStackNavigation').push(Router.getRoute('TabScreenB'));
, and this automatically loadstabNavigationB
withstackNavigationChildB
as a child. Up to this point everything is working as expected, and the current state iscurrentNavigatorUID === 'stackNavigationChildB'
;The issue happens when the user taps a button to return to
tabNavigationA
. This makes a callnavigation.getNavigator('rootStackNavigation').pop()
, which has a very unexpected result. The following Redux actions get dispatched.First:
Which results in the state
currentNavigatorUID === 'stackNavigationChildA'
;Second:
Which results in the state
currentNavigatorUID === 'tabNavigationB'
;In the app, the user is now looking at
stackNavigationChildA
(which is contained withintabNavigationA
), which is correct, howevercurrentNavigatorUID
is incorrect, it is nowtabNavigationB
when it should bestackNavigationChildA
.I believe this is happening because the action to remove the
stackNavigationChildB
navigator is happening after the action to remove thetabNavigationB
navigator (which is its parent), when it should be the other way around. So the action to removetabNavigationB
happens and the resulting state is correct at this point, but then the action to removestackNavigationChildB
happens and ExNavigation sees thattabNavigationB
is the parent ofstackNavigationChildB
, so it setscurrentNavigatorUID
totabNavigationB
.This problem is causing issues with me using functionality like
NavigationActions.showLocalAlert()
, where I need to be able to pass in the correctcurrentNavigatorUID
so that the alert is shown in the right navigator, but sincecurrentNavigatorUID
becomes incorrect and inconsistent with what the user is actually seeing on their screen, if I try to show an alert they won't see it since it's shown in a navigator that is no longer visible.