changes made to firebase currentUser is not reflected until full reload of the application [duplicate]

孤者浪人 提交于 2021-02-11 13:48:05

问题


I want to update displayName of the current user and display it on screen.

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);

using this code it is returning null on first but when I reload the app it is returning 'John Doe' how can i do it without reloading app.


回答1:


Call reload() on the user object after updating the profile. Note that it returns a promise to indicate when that's done.



来源:https://stackoverflow.com/questions/61416247/changes-made-to-firebase-currentuser-is-not-reflected-until-full-reload-of-the-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!