Reputation: 358
I'm struggling with what I would hope is a simple issue. I have multiple StackNavigators with various screens. Like this:
Main Stack
Main Screen (entry)Chat Stack
Chat list
Chat Details Screen
Add Member to list
Invite friend to chat
On the Chat List a user can navigate to Invite friend to chat screen. So Chat List Screen > Invite friend to chat screen. This works great, as it does throughout the app.
Navigation in the same stack works great both forward. I'm using the standard .navigate to move forward.
this.props.navigation.navigate('Invite friend to chat')
Here after successfully inviting friend i am navigating to Chat List screen.
Here i want to remove active screen from stack while navigating to new screen
Link Referred React-Navigation
E.g.
Going back from a specific screen Consider the following navigation stack history: navigation.navigate(SCREEN_KEY_A); ... navigation.navigate(SCREEN_KEY_B); ... navigation.navigate(SCREEN_KEY_C); ... navigation.navigate(SCREEN_KEY_D); Now you are on screen D and want to go back to screen A (popping D, C, and B). Then you need to supply a key to goBack FROM: navigation.goBack(SCREEN_KEY_B) // will go to screen A FROM screen B
Upvotes: 1
Views: 860
Reputation: 9684
Your question isn't totally clear to me, but it sounds like you'd like this behavior...
A > B > C > D > goBack() => A
Would the following also be true?
A > B > C > goBack() => A
A > B > goBack() => A
A > goBack() => A
If so, then rather than navigation.navigate()
which pushes a new scene onto the navigation stack, you'll want to use navigation.reset()
. For more information, see the React Navigation Docs (Reset)
Upvotes: 1