-1

I'm trying to use the library react-native-navigation v2, i need some help I'm stuck with the side menu, i can't make it work...

I initialized my layout like this :

Navigation.events().registerAppLaunchedListener(() => {
Navigation.setRoot({
    root: {
        sideMenu: {
            id: "sideMenu",
            left: {
                component: {
                    id: "Drawer",
                    name: "navigation.Drawer"
                }
            },
            center: {
                stack: {
                    id: "AppRoot",
                    children: [
                        {
                            component: {
                                id: "App",
                                name: "navigation.AppScreen"
                            }
                        }
                    ]
                }
            }
        }
    }
});

});

With Components registered before, and in the Drawer component I want that when the user click on the item, it will trigger the goToScreen2(),

I tried : Navigation.setStackRoot(this.props.componentId, {...} Navigation.mergeOptions(this.props.componentId, {...} Navigation.push(this.props.componentId, {...}

But, none works... someone can explain how can i make it works ?

Thanks.

J-Barbe
  • 29
  • 4

1 Answers1

0

You should add all the components that you want to navigate to from side menu in the center of your root stack as the following:

center: {
   stack: {
    id: "AppRoot",
    children: [{
        component: {
        id: "anyID",
        name: "Screen2"
        }
    }]
  }
}
leopal
  • 4,711
  • 1
  • 25
  • 35
Fatema
  • 11
  • 1
  • This makes drawer acting like a stack instead like a drawer. When i'm pushing the new screen, the drawer closes ( because i ask him to do it ) but i've a return button which lead to the last screen. So even if i remove this return button, it keeps the whole navigation stack on memory... The only way i found atm is to use `setStackRoot` – J-Barbe Jan 02 '19 at 19:53
  • @Fatema if The first screen is "login" and for simplicity sake, user just clicks on "login" to go to the "logged in" screen. Do I need to add those screens in center? – user2763557 Apr 09 '19 at 19:41