【发布时间】:2021-02-28 13:46:46
【问题描述】:
如果用户输入错误的密码,如何停止导航。发现错误后,我的应用程序仍在重定向。我已经尝试过这个简单的 If 条件,但它似乎不起作用。
login = (email,password)=>{
try{
firebase.auth().signInWithEmailAndPassword(email,password)
.then(function(user){
console.log(user)
});
}
catch(error){
console.log(error.toString())
if(error===true) {
return; //stop the execution of function
}
}
this.props.navigation.replace('Home')
}
【问题讨论】:
-
为什么要在 Promise 回调之外导航?我认为导航应该依赖auth响应,所以应该放在
then块中
标签: javascript reactjs react-native react-navigation