Javascript 在完全重新加载应用程序之前,不会反映对firebase currentUser所做的更改

Javascript 在完全重新加载应用程序之前,不会反映对firebase currentUser所做的更改,javascript,reactjs,firebase,react-native,firebase-authentication,Javascript,Reactjs,Firebase,React Native,Firebase Authentication,我想更新当前用户的displayName并在屏幕上显示它 firebase .auth() .createUserWithEmailAndPassword(email, password) .then((response) => {response.user.updateProfile({displayName: 'John Doe'}),response.user.reload()}) .catch(error =>

我想更新当前用户的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”,我如何在不重新加载应用程序的情况下执行此操作。

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

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