Skip to content

How to navigate from parent StackNavigator to child StackNavigator inside a DrawerNavigator #2398

@maggialejandro

Description

@maggialejandro

This is my current nav stack:

const AppNavigator = StackNavigator({
  Welcome: {
    screen: WelcomeScreen,
  },
  Login: {
    screen: LoginScreen,
  },
  Main: {
    screen: ({ navigation }) => <DrawerNavigator screenProps={{ rootNavigation: navigation }} />,
    path: 'main',
  },
}, { headerMode: 'none' });
const DrawerNav = DrawerNavigator({
  Home: {
    screen: HomeScreen,
  },
  Notifications: {
    screen: NotificationsNavigator,
  },
}, {
  initialRouteName: 'Home',
  contentComponent: DrawerContent,
});

NotificationsNavigator is a Stack navigator with routes: Notifications and Notification

I handle Push Notifications logic on WelcomeScreen (I also check here if the user is logged in)
What I need is to navigate from Welcome to Notification (Stack -> Drawer -> Stack)

I'm trying this, in WelcomeScreen:

const navigateAction = NavigationActions.navigate({
  routeName: 'Main',
  action: NavigationActions.navigate({
    routeName: 'Notification',
    params: { notificationId: '355' },
  }),
});

navigation.dispatch(navigateAction);

Current Behavior

It navigates to Home.

First the action Navigation/INIT appears in AppNavigator
Then it appears the action I dispatch
Then in DrawerNav the action Navigation/INIT is shown.

(Promocion == Notification)
captura de pantalla 2017-08-16 a la s 11 10 44

software version
react-navigation 1.0.0-beta.11
react-native 0.45.1
node 7.10.0
npm or yarn 4.2.0 / 0.17.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions