I'm running a react native project, and I with Firebase as my database. I made a sign up page that grabs an Email, username and password from the user. I used the SignUpWithEmailAndPassword function, after that I use the update profile and add the username input as the displayName value over here:
firebase
.auth()
.createUserWithEmailAndPassword(email, password)
.then((res) => {
console.log(res);
firebase.firestore().collection("users").add({
email: email,
username: username,
password: password,
});
firebase.auth().currentUser.updateProfile({
displayName: username,
photoURL: "",
});
console.log(firebase.auth().currentUser.displayName);
Now the display name gets saved, but it doesn't update it's value until I refresh one time. So the console.log returns a null instead of the display name after the user submits his info. What's the problem here?