title: How to await for the response of Alert dialog in React Native?
body: <p>From my observation, the <code>Alert</code> dialog seems built on top of the React Native app.
  So it pops out everytime you call it, and doesn't to be in the <code>render</code> function.<br>
  The catch is it is not an async task so the code after <code>Alert</code> will continue to execute regardless the callback function. </p>
  
  <p>The code below demonstrates a situation where the <code>Alert</code> dialog keeps popping out because it reads the same barcode over and over again.<br>
  (It is written in TypeScript. Just take my word, this is a valid snippet.)</p>
  
  <pre><code> import * as React from "react";
   import Camera from "react-native-camera";
   import { Alert } from "react-native";
  
   export default class BarcodeScanSreen extends React.Component&lt;any ,any&gt; {
   private _camera;
   private _onBarCodeRead = e =&gt; {
      if (e.type === "QR_CODE") {
          Alert.alert(
              "QRCode detected",
              "Do you like to run the QRCode?",
              [
                  { text: "No", onPress: this._onNoPress },
                  { text: "Yes", onPress: this._onYesPress }
              ],
              { cancelable: false }
          );
      }
  };
  
   private _onYesPress = () =&gt; { /* process the QRCode */ }
  
   private _onNoPress = () =&gt; { /* close the alert dialog. */ }
  
  render() {
      return (
          &lt;Camera
              onBarCodeRead={this._onBarCodeRead}
              aspect={Camera.constants.Aspect.fill}
              ref={ref =&gt; (this._camera = ref)}
          &gt;
              {/* Some another somponents which on top of the camera preview... */}
          &lt;/Camera&gt;
      );
  }
  }
  </code></pre>
  
  <p>Is there a way to pause the JS code and await the response from <code>Alert</code>?</p>