title: Setting asynchronous value to a variable not working
body: <p>First take a look at the code</p>
  <pre><code>AsyncStorage.getItem(&quot;CartItem&quot;).then(val =&gt; console.log(val))
  </code></pre>
  <p>When I run it, it logs this array of objects</p>
  <pre><code>[{&quot;id&quot;:&quot;6084844531f6aa1a980272e6&quot;,&quot;name&quot;:&quot;Garlic&quot;,&quot;price&quot;:300,&quot;qty&quot;:10,&quot;totalPrice&quot;:3000,&quot;image&quot;:&quot;Some image&quot;}]
  </code></pre>
  <p>I need that value which is returning from AsyncStorage to be assigned to a global variable like this</p>
  <pre><code>var cart
  AsyncStorage.getItem(&quot;CartItem&quot;). then(val =&gt; cart = val)
  console.log(cart)
  </code></pre>
  <p>But the cart variable doesn't affect it logs <code>undefined</code></p>
  <p>It's a function in react-native not a component, so please don't say store the <code>val</code> to state</p>
  <p>Any help will be appreciated, thanks in advance</p>