title: How to get the value of useRef current in React Native
body: <p>I am developing a React Native application and am facing the following error:</p>
  <p>I have defined a <code>useRef</code> which stores the doc ID from a firebase collection. But when I call that variable after it has been defined, the <code>.current</code> value returns a blank string.</p>
  <pre><code>db.collection('users').onSnapshot((snapshot) =&gt; {
      snapshot.docs.map((doc) =&gt; {
          if (doc.data().email === auth.currentUser?.email) {
              bidId.current = doc.id
              console.log(bidId.current)
          }
      })
  })
  </code></pre>
  <p>The above code returns the expected value. However, when I call the variable outside this <code>db.collection</code>  loop, I get the following value:</p>
  <p><a href="https://i.stack.imgur.com/bMyj5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bMyj5.png" alt="enter image description here" /></a></p>
  <p>But calling the bidId.current returns a blank string.</p>
  <p>Please can someone help me with this. Thanks!</p>