I'm new in react-native, i'm trying to build an app with a router and a side-menu with some links to others pages inside this menu.
Well, i'm actually using gb-native-router and react-native-side-menu to do this. Actually i've found 2 solutions.
First solution :
<SideMenu menu={menu}> //here, the sidemenu is outside the router, i can't put in inner (the chat will slide but not the Navigator)
<Router
firstRoute={Routes.Main.App}
headerStyle={Styles.NavBar.container}
titleStyle={Styles.NavBar.navContent}
borderBottomWidth={Styles.Props.NavBar.borderBottomWidth}
borderColor={Styles.Props.NavBar.borderColor}
/>
</SideMenu>
Second solution :
Include the side-menu in the test.js file (see link) to do something like this :
<SideMenu menu={menu}>
<View><Chat /></View>
</SideMenu>
Problem : The first solution is working well, but when i'm trying to do "this.props.toRoute({})", this function is not defined (because the side-menu isn't in the router i guess) And the second solution, the router (Navigator) will not move with the rest of the page when i'm accessing to the side-menu (because he is not in the side-menu :p).
Any Help for this probem ? I think i can use NSNotificationCenter to send a signal to all app, and add a listener inside the router to try to route properly ... But I would like to find a more simple and better way.
You can see more code here : https://rnplay.org/apps/Xr8PPA
Thanks for your help !
EDIT :
Here, a short code of index.js from react-native-side-menu :
render() {
let menu = null;
/**
* If menu is ready to be rendered
*/
if (this.state.shouldRenderMenu) {
menu = <View style={styles.menu}>{this.props.menu}</View>;
}
return (
<View style={styles.container} onLayout={this.onLayoutChange.bind(this)}>
{menu}
{this.getContentView()}
</View>
);
}
It seems that my menu from menu.js is only render in a view. So i don't know how to access router from here ... :(