I found a problem to update profile firebase in React Native, I try to look for example but fails all, maybe you can give me advices or you can correct my script.
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);
});
I try to follow all examples, in the alert shows message 'user.updateProfile is not a function'.
Please anyone help me how to update profile (displayName) firebase in React Native.
Thanks.
The createUserWithEmailAndPassword
method returns a UserCredential
object . This is not a User
itself, but has a user
property, which is a User
object .
So what you need it:
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);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.