我想更新当前用户的displayName并将其显示在屏幕上。
firebase
.auth()
.createUserWithEmailAndPassword(email, password)
.then((response) => {response.user.updateProfile({displayName: 'John Doe'}),response.user.reload()})
.catch(error => Alert.alert('', error.message));
console.log(firebase.auth().currentUser.displayName);
使用此代码,它首先返回 null,但是当我重新加载应用程序时,它返回“John Doe”,如何在不重新加载应用程序的情况下执行此操作。
最佳答案
调用reload()更新配置文件后在用户对象上。请注意,它会返回一个 promise 来指示何时完成。
关于javascript - 对 firebase currentUser 所做的更改只有在完全重新加载应用程序后才会反射(reflect)出来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61416247/