Cannot properly navigate between two different stacks in react native and keep back functionallity
up vote
0
down vote
favorite
Currently these are my screens in my react native app.
Root Nav - (SwitchNavigator)
Stack A - (BottomTabNavigator)
Page A
Page B
Stack B - (StackNavigator)
Page C
Page D
I am trying to navigate to page C/D
From pages A/B
But when I try to navigate using this.props.navigation.navigate()
It will navigate correctly, but the history functionality such as swiping right or calling goBack()
to go to the previous page (in a different stack) does not work.
When navigating to page D
and swiping right, it goes to page C
and swiping right again does not do anything.
react-native react-navigation
add a comment |
up vote
0
down vote
favorite
Currently these are my screens in my react native app.
Root Nav - (SwitchNavigator)
Stack A - (BottomTabNavigator)
Page A
Page B
Stack B - (StackNavigator)
Page C
Page D
I am trying to navigate to page C/D
From pages A/B
But when I try to navigate using this.props.navigation.navigate()
It will navigate correctly, but the history functionality such as swiping right or calling goBack()
to go to the previous page (in a different stack) does not work.
When navigating to page D
and swiping right, it goes to page C
and swiping right again does not do anything.
react-native react-navigation
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Currently these are my screens in my react native app.
Root Nav - (SwitchNavigator)
Stack A - (BottomTabNavigator)
Page A
Page B
Stack B - (StackNavigator)
Page C
Page D
I am trying to navigate to page C/D
From pages A/B
But when I try to navigate using this.props.navigation.navigate()
It will navigate correctly, but the history functionality such as swiping right or calling goBack()
to go to the previous page (in a different stack) does not work.
When navigating to page D
and swiping right, it goes to page C
and swiping right again does not do anything.
react-native react-navigation
Currently these are my screens in my react native app.
Root Nav - (SwitchNavigator)
Stack A - (BottomTabNavigator)
Page A
Page B
Stack B - (StackNavigator)
Page C
Page D
I am trying to navigate to page C/D
From pages A/B
But when I try to navigate using this.props.navigation.navigate()
It will navigate correctly, but the history functionality such as swiping right or calling goBack()
to go to the previous page (in a different stack) does not work.
When navigating to page D
and swiping right, it goes to page C
and swiping right again does not do anything.
react-native react-navigation
react-native react-navigation
asked Nov 8 at 19:06
person
457
457
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Different stacks are meant to stand on their own, so if what you need is to keep the navigation history between those screens, you have to set them up in the same stack. Stacks can be set up in your flow just like screens, for example, setting up a stack navigator inside a drawer navigator:
/**
* User drawer stack
*/
const DrawerStack = DrawerNavigator(
Home: screen: HomeStack, //HomeStack is a StackNavigator
,
contentComponent: DrawerContainer,
initialRouteName: 'Home',
);
With this rethink what you want your history like. If I understood your use case correctly, you want A/B to share history with C/D, I'd say you need your stack to be like:
Root Nav - (SwitchNavigator)
Stack B - (StackNavigator)
Stack A - (BottomTabNavigator)
Page A
Page B
Page C
Page D
If you can't do that for some reason, then you will need to capture back presses and swipes manually to do the behavior yourself.
Thanks so much!!!, Couldn't figure out why it wasn't working but this helped a ton.
– person
Nov 8 at 20:28
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Different stacks are meant to stand on their own, so if what you need is to keep the navigation history between those screens, you have to set them up in the same stack. Stacks can be set up in your flow just like screens, for example, setting up a stack navigator inside a drawer navigator:
/**
* User drawer stack
*/
const DrawerStack = DrawerNavigator(
Home: screen: HomeStack, //HomeStack is a StackNavigator
,
contentComponent: DrawerContainer,
initialRouteName: 'Home',
);
With this rethink what you want your history like. If I understood your use case correctly, you want A/B to share history with C/D, I'd say you need your stack to be like:
Root Nav - (SwitchNavigator)
Stack B - (StackNavigator)
Stack A - (BottomTabNavigator)
Page A
Page B
Page C
Page D
If you can't do that for some reason, then you will need to capture back presses and swipes manually to do the behavior yourself.
Thanks so much!!!, Couldn't figure out why it wasn't working but this helped a ton.
– person
Nov 8 at 20:28
add a comment |
up vote
1
down vote
accepted
Different stacks are meant to stand on their own, so if what you need is to keep the navigation history between those screens, you have to set them up in the same stack. Stacks can be set up in your flow just like screens, for example, setting up a stack navigator inside a drawer navigator:
/**
* User drawer stack
*/
const DrawerStack = DrawerNavigator(
Home: screen: HomeStack, //HomeStack is a StackNavigator
,
contentComponent: DrawerContainer,
initialRouteName: 'Home',
);
With this rethink what you want your history like. If I understood your use case correctly, you want A/B to share history with C/D, I'd say you need your stack to be like:
Root Nav - (SwitchNavigator)
Stack B - (StackNavigator)
Stack A - (BottomTabNavigator)
Page A
Page B
Page C
Page D
If you can't do that for some reason, then you will need to capture back presses and swipes manually to do the behavior yourself.
Thanks so much!!!, Couldn't figure out why it wasn't working but this helped a ton.
– person
Nov 8 at 20:28
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Different stacks are meant to stand on their own, so if what you need is to keep the navigation history between those screens, you have to set them up in the same stack. Stacks can be set up in your flow just like screens, for example, setting up a stack navigator inside a drawer navigator:
/**
* User drawer stack
*/
const DrawerStack = DrawerNavigator(
Home: screen: HomeStack, //HomeStack is a StackNavigator
,
contentComponent: DrawerContainer,
initialRouteName: 'Home',
);
With this rethink what you want your history like. If I understood your use case correctly, you want A/B to share history with C/D, I'd say you need your stack to be like:
Root Nav - (SwitchNavigator)
Stack B - (StackNavigator)
Stack A - (BottomTabNavigator)
Page A
Page B
Page C
Page D
If you can't do that for some reason, then you will need to capture back presses and swipes manually to do the behavior yourself.
Different stacks are meant to stand on their own, so if what you need is to keep the navigation history between those screens, you have to set them up in the same stack. Stacks can be set up in your flow just like screens, for example, setting up a stack navigator inside a drawer navigator:
/**
* User drawer stack
*/
const DrawerStack = DrawerNavigator(
Home: screen: HomeStack, //HomeStack is a StackNavigator
,
contentComponent: DrawerContainer,
initialRouteName: 'Home',
);
With this rethink what you want your history like. If I understood your use case correctly, you want A/B to share history with C/D, I'd say you need your stack to be like:
Root Nav - (SwitchNavigator)
Stack B - (StackNavigator)
Stack A - (BottomTabNavigator)
Page A
Page B
Page C
Page D
If you can't do that for some reason, then you will need to capture back presses and swipes manually to do the behavior yourself.
answered Nov 8 at 19:58
Danilo
1217
1217
Thanks so much!!!, Couldn't figure out why it wasn't working but this helped a ton.
– person
Nov 8 at 20:28
add a comment |
Thanks so much!!!, Couldn't figure out why it wasn't working but this helped a ton.
– person
Nov 8 at 20:28
Thanks so much!!!, Couldn't figure out why it wasn't working but this helped a ton.
– person
Nov 8 at 20:28
Thanks so much!!!, Couldn't figure out why it wasn't working but this helped a ton.
– person
Nov 8 at 20:28
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53214540%2fcannot-properly-navigate-between-two-different-stacks-in-react-native-and-keep-b%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown