当我实现Firebase登录时,Keyboard.dismiss()不起作用。键盘停留在您必须手动关闭它的下一页上。有人知道如何让键盘消失吗?
当我评论Firebase身份验证代码时,那么keyboard.dismiss()可以完美地工作。
但是当我用Firebase身份验证代码Keyboard.dismiss()注释掉时,为什么会发生这种情况?
代码:
handleLogin = () => {
Keyboard.dismiss();
this.setState({ isLoading: true });
const { email, password } = this.state;
firebase
.auth()
.signInWithEmailAndPassword(email, password)
.catch(function(error) {
Alert.alert('Error', error.message);
})
.then(response => {
this.setState({ isLoading: false });
if (response) {
this.setState({ isSuccessful: true });
this.storeName(response.user.email);
setTimeout(() => {
this.props.closeLogin();
this.setState({ isSuccessful: false });
setTimeout(() => {
Alert.alert('Congrats', "You've logged successfully!");
}, 200);
}, 1000);
}
});
};