How to active react-native side menu only first screen of stacknavigation?

时间:2017-06-12 16:45:02

标签: react-native react-native-navigation side-menu

I am so younger with react-native. And currently I am trying to using Stacknavigation with side menu. In this case I want to active side menu only home screen of stacknavigation, but The side menu active all screen of child navigation. Everyone, have any idea with this. here is my code

// the stacknavigator that content with two screen: League(Home)
// and LeagueDetail(Detail)
const MatchStackNavigator = StackNavigator({
          Home: { screen: League, 
          navigationOptions : {
          title : 'Matches',   
 } },
         Detail: {screen: LeagueDetail}
 }, {
         initialRouteName: 'Home'
 })

// Side menu
 class Basic extends Component {
       constructor(props) {
          super(props);

        }
       state = {
          isOpen: false,
          selectedItem: 'League'
        }
       onMenuItemSelected = (item) => {
          this.setState({
          isOpen: false,
          selectedItem: item,
          });
       }
       updateMenuState(isOpen) {
          this.setState({ isOpen, });
       }
       toggle() {
          this.setState({
          isOpen: !this.state.isOpen,
          });
       }

       render() {
       const menu = <Menu onItemSelected={this.onMenuItemSelected} />;
         return (

           <SideMenu
              menu={menu}
             isOpen={this.state.isOpen}
             onChange={(isOpen) => this.updateMenuState(isOpen)}
             bounceBackOnOverdraw={false}
             openMenuOffset = {1}
            >
           <MatchStackNavigator />
           <Button style={styles.button} onPress={() => this.toggle()}>
               <Image
        source={require('../resources/icons/burger-icon2.png')} style={{
          height: 30,
          width: 25,
          tintColor: 'white',
          resizeMode: 'contain',
        }} />
          </Button>
      </SideMenu>
    )
   }
   }

0 个答案:

没有答案