title: Why does displayName not get updated? using onAuthChanged
body: <p>I am using Redux and to persist my auth. Using redux toolkit I have an action that checks <code>onAuthChanged</code> from Firebase Auth.</p>
  <pre><code>export const persistedSession = () =&gt; {
    return async (dispatch) =&gt; {
      dispatch(requestLogin());
      firebaseAuth.onAuthStateChanged(async (user) =&gt; {
        if (user) {
          const currentUser = await createUserProfileDocument(user);
          currentUser.on(&quot;value&quot;, (snapshot) =&gt; {
            var data = snapshot.val();
            if (data !== null) {
              //Success
            }
          });
        }
      });
    };
  };
  </code></pre>
  <p>Then when I check if a document exists for this user and if not create one.</p>
  <pre><code>export const createUserProfileDocument = async (user) =&gt; {
    if (!user) return;
  
    const { uid, displayName, email } = user;
    const userReference = database.ref(&quot;users&quot;);
    userReference.once(&quot;value&quot;, (snapshot) =&gt; {
      if (!snapshot.hasChild(uid)) {
        userReference.child(uid).set({
         ...
        });
      }
    });
    return userReference;
  };
  </code></pre>
  <p>So here is where my issue is. Upon creating my user <code>displayName</code> is always null how can I update user profile correctly? It seems like <code>onAuthChanged</code> is triggered before it can make an update so that displayName will always be null and document will not contain displayName property</p>
  <pre><code>export const registerUser = (value) =&gt; {
    const { firstName, surname, email, password } = value;
    return async (dispatch) =&gt; {
      
      firebaseAuth
        .createUserWithEmailAndPassword(email, password)
        .then(async (result) =&gt; {
          const user = result.user;
          user.updateProfile({
              displayName: `${firstName} ${surname}`,
            })
           
        })
        .catch((error) =&gt; {
          console.log(&quot;Unable to create user profile: &quot;, error);
        });
    };
  };
  </code></pre>