Navigation React本机Redux导航,OnNet onLeave

Navigation React本机Redux导航,OnNet onLeave,navigation,react-native,redux,Navigation,React Native,Redux,我试图调用导航中的children函数。这样就可以在导航所使用的视图中使用onEnter/onLeave函数。但是,我不知道在使用Redux时如何访问这些函数 constructor(props) { super(props); this.state = { viewState: VIEWSTATE_NONE, isConnected: true, }; this._routes = [ // HERE ARE THE VI

我试图调用导航中的children函数。这样就可以在导航所使用的视图中使用onEnter/onLeave函数。但是,我不知道在使用Redux时如何访问这些函数

constructor(props) {
    super(props);
    this.state = {
      viewState: VIEWSTATE_NONE,
      isConnected: true,
    };
    this._routes = [
        // HERE ARE THE VIEWS
      <View></View>,
      <ViewVersion onComplete={this._versionComplete.bind(this)} />,
      <ViewError onSubClickPrev={this.onSubClickPrev.bind(this)} />,
      <ViewLogin onComplete={this._loginComplete.bind(this)} />,
      <ViewLoginCustomer onSubClickPrev={this.onSubClickPrev.bind(this)} />,
      <ViewMain onSubClickPrev={this.onSubClickPrev.bind(this)} />,
    ];
}


  onSubClickGoto(goto){
    this.setState({viewState: goto});
    this._isErrorVisible = false;
    var routesHistory = this.refs.navBase.getCurrentRoutes();
    for(var i = 0; i < routesHistory.length; i++){

      // I CANNOT GET MY NAVIGATION VIEW CLASS HERE
      var view = this._routes[routesHistory[i].index];
      console.log("check obj "+ view + " - " + view.getWrappedInstance); // getWrappedInstance returns undefined
      if(view.getWrappedInstance!=null&&view.getWrappedInstance().onLeave!=null)
        view.getWrappedInstance().onLeave();
    }
    switch(goto){
      case VIEWSTATE_VERSION:
        this.refs.navBase.push({index:1});
        break;
      case VIEWSTATE_ERROR:
        this.refs.navBase.push({index:2});
        break;
      case VIEWSTATE_LOGIN:
        this.refs.navBase.push({index:3});
        break;
      case VIEWSTATE_CUSTOMER:
        this.refs.navBase.push({index:4});
        break;
      case VIEWSTATE_MAIN:
        this.refs.navBase.push({index:5});
        break;
    }
  }


  _renderNavigationBase(route, navigator){
    console.log("render: ", route);
    return this._routes[route.index];
  }

  _configureNavigationBase(route, routeStack){
    console.log("configure: ", route);
    /*
    switch (route.index) {
      case 1:
        return Navigator.SceneConfigs.FloatFromLeft;
      case 2:
        return Navigator.SceneConfigs.FloatFromRight;

    }
    */
    return Navigator.SceneConfigs.FloatFromRight;
  }

  render() {
    return (
      <View style={styles.view} >
        <Navigator
          ref="navBase"
          initialRoute={{index:0}}
          configureScene={this._configureNavigationBase.bind(this)}
          renderScene={this._renderNavigationBase.bind(this)} />
      </View>
    )
  }

你有没有想过?我遇到了相同的问题,getWrappedInstance()返回undefined.No。到目前为止运气不好。在onSubClickGoto中也做了一些丑陋的修复,这取决于from->to.:(你有没有发现这个问题?我遇到了相同的问题,getWrappedInstance()返回未定义的。没有。到目前为止运气不好。onSubClickGoto中也有一些丑陋的修复,这取决于from->to.)(
class ViewLogin extends Component {
    onLeave(){
      console.log("DISMISS ");
      dismissKeyboard();
    }
}

ViewLogin.contextTypes = {
    store: PropTypes.object
};
export default connect(mapStateToProps,mapDispatchToProps,null,{withRef:true})(ViewLogin);