react-native-side-menu
react-native-side-menu copied to clipboard
Change the whole content of the side menu
How can I replace the content component by another one when a menu item gets selected? Is there a method like replace(..)?
You can predefine your content component based on props/state. For example, you can use a switch/case statement that
@Kureev do you mean something like this?
...
render() {
const menu = <Menu navigator={navigator}/>;
return (
<SideMenu menu={menu}>
{this.renderContent()}
</SideMenu>
);
}
renderContent() {
switch (this.state.selectedIndex) {
case '1':
return <ContentViewOne/>;
case '2':
return <ContentViewTwo/>;
case '3':
return <ContentViewThree/>;
default:
return <ContentViewFour/>;
}
}
...