Fra*_*rew 3 javascript firebase react-native firebase-authentication
我在 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);
});
Run Code Online (Sandbox Code Playgroud)
我尝试遵循所有示例,在警报中显示消息“user.updateProfile 不是函数”。
请任何人帮助我如何在 React Native 中更新配置文件 (displayName) firebase。
谢谢。
Fra*_*len 16
该createUserWithEmailAndPassword方法返回一个UserCredential对象。这不是 aUser本身,而是具有一个user属性,即一个Userobject。
所以你需要它:
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);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4702 次 |
| 最近记录: |