在完全重新加载应用程序之前,不会反映对firebase currentUser所做的更改 [英] changes made to firebase currentUser is not reflected until full reload of the application

查看:37
本文介绍了在完全重新加载应用程序之前,不会反映对firebase currentUser所做的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更新当前用户的displayName并将其显示在屏幕上.

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

使用此代码,它首先返回null,但是当我重新加载应用程序时,它返回"John Doe",如何在不重新加载应用程序的情况下完成操作.

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.

推荐答案

调用 reload().请注意,它会返回一个承诺以指示完成的时间.

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

这篇关于在完全重新加载应用程序之前,不会反映对firebase currentUser所做的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆