![](/img/trans.png)
[英]Firebase Update Profile Not Updating profile in First Attempt || Promise NoT Handling || displayName
[英]How to update profile (displayName) firebase in React Native?
我在React Native中發現了更新配置文件Firebase的問題,我嘗試舉例,但全部失敗,也許您可以給我建議或可以更正我的腳本。
firebase.auth().createUserWithEmailAndPassword(this.state.email, this.state.password)
.then(
(user)=>{
if(user){
user.updateProfile({
displayName: 'Frank S. Andrew'
}).then((s)=> {
this.props.navigation.navigate('Account');
})
}
})
.catch(function(error) {
alert(error.message);
});
我嘗試遵循所有示例,在警報中顯示消息“ user.updateProfile不是函數”。
請任何人幫助我如何在React Native中更新配置文件(displayName)Firebase。
謝謝。
createUserWithEmailAndPassword
方法返回一個UserCredential
對象 。 這不是User
本身,而是具有 user
屬性,它是User
對象 。
因此,您需要什么:
firebase.auth().createUserWithEmailAndPassword(this.state.email, this.state.password)
.then((userCredentials)=>{
if(userCredentials.user){
userCredentials.user.updateProfile({
displayName: 'Frank S. Andrew'
}).then((s)=> {
this.props.navigation.navigate('Account');
})
}
})
.catch(function(error) {
alert(error.message);
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.