我的注销功能如下所示。以及我如何实现它。不确定是什么导致我的承诺以未定义的方式返回。这不是一个具有约束力的问题。我已经测试过了。
logout() {
firebase.auth().signOut()
.then((respnose) => {
console.log(respnose)
})
.catch((error) => {
console.log('error on logging out: ' + error)
})
}
<Header
statusBarProps={{ barStyle: 'light-content' }}
leftComponent={{ icon: 'menu', color: '#fff' }}
centerComponent={{ text: 'Chat Room', style: { color: '#fff' } }}
rightComponent={<Icon name='logout' color='white' type='material-community' onPress={this.logout}/>}
/>
我正在使用react-native-elements。
答案 0 :(得分:0)
尝试这样,因为成功时它没有响应,但是在出错时它有一个错误对象,所以实际上你已成功注销但是由于响应未定义而出现错误
const thisClass = this; // here is how you assign this to variable
firebase.auth().signOut().then(() => {
// Sign-out successful.
console.log('Signed Out');
thisClass.props.myProp // here is how you can access this.props
thisClass.setState({ myNewState }) // here is how you can set the state
}, (error) => {
console.log(error);
});