问题
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