传递给NavigationBar时,为什么不调用函数routeMapper(react-native-drawer)React Native?

时间:2016-07-21 03:20:40

标签: javascript ios react-native react-jsx

我正在尝试从https://github.com/root-two/react-native-drawer实现react-native-drawer,而我传递给NavigationBarRouteMapper的变量正确记录openDrawer()函数,但是当单击左侧导航按钮“Open Menu”时,它什么也没做:

class practice extends Component {
...

  openDrawer(){
    this._drawer.open()
  }

  render() {
    return (
  <Drawer
    content={<DrawerPanel/>}
    openDrawerOffset={100}
    ref={(ref) => this._drawer = ref}
    type='static'
    tweenHandler={Drawer.tweenPresets.parallax}
  >
        <Navigator
          configureScene={this.configureScene}
          initialRoute={{name: 'Start', component: Start}}
          renderScene={this.renderScene}
          style={styles.container}
          navigationBar={
            <Navigator.NavigationBar
              style={styles.navBar}
              routeMapper={NavigationBarRouteMapper(this.openDrawer)}
            />
          }
        />
  </Drawer>
    );
  }
}

var NavigationBarRouteMapper = openDrawer => ({
  LeftButton(route, navigator, index, navState){
      return(
          <TouchableHighlight onPress={()=>{openDrawer}}>
              <Text>Open Menu</Text>
          </TouchableHighlight>
      )
    }
  },...

什么可能阻止抽屉打开?好像一切都已正确实施。

0 个答案:

没有答案