react-native-side-menu icon indicating copy to clipboard operation
react-native-side-menu copied to clipboard

Change the whole content of the side menu

Open yeldarxman opened this issue 8 years ago • 2 comments

How can I replace the content component by another one when a menu item gets selected? Is there a method like replace(..)?

yeldarxman avatar Oct 02 '16 04:10 yeldarxman

You can predefine your content component based on props/state. For example, you can use a switch/case statement that

Kureev avatar Oct 02 '16 13:10 Kureev

@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/>;
    }
}
...

yeldarxman avatar Oct 03 '16 03:10 yeldarxman