【问题标题】:changes made to firebase currentUser is not reflected until full reload of the application [duplicate]在完全重新加载应用程序之前,不会反映对 firebase currentUser 所做的更改[重复]
【发布时间】:2020-08-08 11:47:48
【问题描述】:

我想更新当前用户的 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”,我如何在不重新加载应用程序的情况下做到这一点。

【问题讨论】:

  • 请不要多次转发同一个问题。相反,请对您最初发布的问题添加任何说明。它下面有一个方便的编辑链接,可以让你这样做。当您编辑您的问题时,它就有资格重新打开。

标签: javascript reactjs firebase react-native firebase-authentication


【解决方案1】:

更新配置文件后在用户对象上调用reload()。请注意,它会返回一个承诺以指示何时完成。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-27
    • 2011-04-19
    相关资源
    最近更新 更多