2

我对 react-native 这么年轻。目前我正在尝试将 Stacknavigationside menu一起使用。在这种情况下,我只想激活stacknavigation的主屏幕的侧边菜单,但侧边菜单激活子导航的所有屏幕。大家对此有什么想法。这是我的代码

// 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>
    )
   }
   }
4

0 回答 0