1

consider following navigation tree in react-native app.

RootStackNavigator (id of navigator = root)
   Screen A
   Screen B
   EditTabNavigator (params: {id: number})
        Tab A
        Tab B  
        StackNavigator
            Screen D (initial)
            Screen E

Screen E is active screen and I want from here update the id param of EditTabNavigator, stay on Screen E and preserve the initial Screen D of StackNavigator so that back button works on Screen E.

What I tried so far but non of it worked:

navigation.getParent("root").navigate("EditTabNavigator", {
   id: newId,
   screen: "StackNavigator",
   initial: false,
   params: {
      screen: Screen E
   }
})

---------------------------

navigation.getParent("root").replace("EditTabNavigator", {
   id: newId,
   screen: "StackNavigator",
   initial: false,
   params: {
      screen: Screen E
   }
})

---------------------

navigation.getParent("root").reset({
   index: 0,
   routes: [
      {
         name: 'EditTabNavigator',
         params: {
            id,
            screen: 'StackNavigator',
            initial: false,
            params: {
              screen: 'Screen E',
            },      
         }, 
     },
   ]
})

Each of the attempts ended on initial Screen D of StackNavigator but not on desired Screen E. When I removed initial: false it worked, but then back button didn't go to Screen D but to EditTabNavigator which is not good.

Any ideas how to fix it?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.