title: Get firebase.auth().currentUser with async/await
body: <p>I successfully check user's authentication state with onAuthStateChange observer and redirect user to the Dashboard page (react-native project). However, on the dashboard I already want to show some user specific data, e.g. enrolled programs/statistics. For that I need currentUser object to be initialised and populated, which takes some time (I need uid from there to get some data from Database). Thus, i'm looking for some way to wait until this process finishes successfully. What I'm trying to do it to use async/await syntax in componentDidMount, but the result returned is null. (Same syntax successfully works in other screens, but fails in the first one)</p>
  
  <pre><code>async componentDidMount() {
    try {
      let uid = await firebase.auth().currentUser.uid;
      console.log(uid);
    } catch(error) {
      console.log(error);
    }
  }
  </code></pre>
  
  <p><strong>What could be the best way to wait for currentUser object being loaded using async/await syntax?</strong> I believe that the reason could be that firebase returns null as the first result and then correct uid as the second one.</p>
  
  <p>For now for the workaround, I'm using simple setInterval function, but I do not want to increase amount of loading time that much.</p>
  
  <pre><code>  let waitForCurrentUser = setInterval(() =&gt; {
      if ( firebase.auth().currentUser.uid !== null ) {
          clearInterval(waitForCurrentUser);
          let uid = firebase.auth().currentUser.uid;
          this.setState({uid});
          return firebase.auth().currentUser.uid;
      } else {
        console.log('Wait for it');
      }
    }, 700);
  </code></pre>