-
-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to actually use reset from a nested navigator? #1949
Comments
You can pass down the root navigation object as a prop on your child routes. Instead of using component name in your route config, you can render a component.
Main: {
screen: ({ navigation }) =>
<Main screenProps={{ rootNavigation: navigation }} />,
} Account: onPress={() => {
props.rootNavigation.dispatch(
NavigationActions.reset({
index: 0,
actions: [NavigationActions.navigate({ routeName: 'Login' })]
})
)
}} |
That is how I currently achieve that need. |
@iRoachie Do you have any advice on how I can make this work with Redux? If I use your method, the nested Navigator isn't connected to my redux store anymore. |
@jsoendermann Not sure mate, haven't used react-navigation with redux as yet. Passing down props currently works for my needs |
I see, thanks anyway. |
@iRoachie work fine, thanks |
|
I've made some progress with @iRoachie's approach; however, I seem to be passing down the "AuthTab" navigator into the "AppTab" at the TabRoutes configuration level, which I'm debugging.... @augustoabreu Your solution is what I see in a lot of places, passing |
Here's how I'm passing my TabNavigation({
SplashTab: {
screen: SplashScreen,
navigationOptions: { title: 'Splash' }
},
IntroTab: {
screen: IntroScreen,
navigationOptions: { title: 'Intro'}
},
AuthTab: {
screen: AuthNavigator,
navigationOptions: { title: 'Auth' }
},
AppTab: {
screen: ({ navigation }) => <AppDrawer screenProps={{ rootNavigation: navigation }} />,
navigationOptions: { title: 'App' }
}
}, {
initialRouteName: 'SplashTab',
backBehavior: 'none',
swipeEnabled: false,
tabBarPosition: 'bottom',
lazy: true,
animationEnabled: true,
navigationOptions: {
tabBarVisible: false
}
}) |
Thanks @augustoabreu, I was having the same problem and I'm using Redux to manage my navigation state, and your solution worked for me. |
@RobertSheaO yes, when key property is set to @jordanmkoncz you are welcome |
I found a stupid solution, but its working probably. #1715 |
@iRoachie 's solution works for me. However, if I create screen as component, I cannot hide TabNavigator in static navigationOptions, which works before.
I'm not sure if it is a bug or not. Really frustrated now. |
Hi! In an effort to get the hundreds of issues on this repo under control I'm closing issues tagged as questions. Please don't take this personally - it's simply something we need to do to get the issues to a manageable point. If you still have a question I encourage you to re-read the docs, ask on StackOverflow, or ask on the #react-navigation Reactiflux channel. Thank you! |
Here's how I do it with redux:
|
current: now i move to screen1(searchStack) -> screen2(searchStack) -> screen1(bookingStack) expectation: screen1(searchStack) -> screen2(searchStack) -> (now first i want to clear the stack history of searchStack and then move to (screen1)bookingStack) Someone please tell me some idea to get this. Currently i am trying to get this by:
or if i give like this,
|
Months later, still can't figure out how to use
reset()
properly.Looking through all the open and closed issues regarding the usage of
reset()
gives no clear direction on how to actually use it properly. A lot of people have stacks on stacks on stacks and it just doesn't work.For example, my app is a
TabNavigator
, and one of my tabs is aDrawerNavigator
, and each item in the drawer is aStackNavigator
, so if I'm inside a StackNavigator and want toreset()
to a different tab, I'm SOL... I get your standard "the route doesn't exist, use one that's available inside the StackNavigator you're currently in" message.My Structure
My Reset
The text was updated successfully, but these errors were encountered: