导航不起作用

时间:2017-05-30 11:18:29

标签: react-native react-navigation

我有一个注册页面,当用户注册时,我希望应用程序将他移动到主页。 我有一个登录页面,登录后用户被移动到主页。 我尝试用我的注册页面做同样的事情,但它不会将用户移动到主页。我没有任何错误,应用程序不会崩溃。这是代码:

handlePress:

  handlePress(navigate){
    if(this.state.password == this.state.verify){
      firebaseRef.auth().createUserWithEmailAndPassword(this.state.email, this.state.password).then(function(newUser){
        //good
         navigate("home");
      }).catch(function(error){
        //bad
      });
    }else{
      //password not match, show error.
    }
  }

用户确实会注册并显示在firebase中。

这是我调用handlePress的地方:

<TouchableOpacity style={styles.subButtom} onPress={()=>this.handlePress(navigate)}>
  <Text style={styles.subTxt}>
  Register
  </Text>
  </TouchableOpacity>

导航(导航在渲染功能中):

const { navigate } = this.props.navigation;

这是在我的登录页面上工作,但不在注册页面中。

0 个答案:

没有答案
相关问题