title: Add a condition to allow a scan
body: <p>I want to add a condition in my code and for that, I would like your help.
  To explain the purpose of this screen: I have a camera used to scan tickets at an event.
  I want to force the user to first choose the event for which he wants to scan the ticket thanks to the implementation of an autocomplete input that I made thanks to the package</p>
  <blockquote>
  <p>'react-native-dropdown-autocomplete'</p>
  </blockquote>
  <p>So, I don't really know how to do this, adding a condition to prevent the user from scanning his QrCode / Barcode before having selected his event.
  Where do you think I can put my condition? And how do you put it in place ?</p>
  <p>Thanks for all the time you spent helping me. :)</p>
  <pre><code>class Tickets extends Component {
    constructor(props) {
      super(props);
      this.state = {
        Press: false,
        hasCameraPermission: null,
        name: '',
        lastScannedUrl:null,
        displayArray: []      
      };
    }
     initListData = async () =&gt; {
      let list = await getProducts(1);
     
      if (list) {
        this.setState({
          displayArray: list,
          name: list.name
        });      
      }
      //console.log('reference dans initListData =', list.reference)
    };
  
    async UNSAFE_componentWillMount() {
      this.initListData();
      //console.log('reference dans le state =', this.state.reference)
  };
  
    componentDidMount() {
      this.getPermissionsAsync(); 
    }
  
    getPermissionsAsync = async () =&gt; {
      const { status } = await Permissions.askAsync(Permissions.CAMERA);
      this.setState({ hasCameraPermission: status === &quot;granted&quot; });
    };
  
    handleBarCodeScanned = ({ type, data }) =&gt; {
      this.setState({ Press: false, scanned: true, reference: data });
      this.props.navigation.navigate('ProductDetails', {reference : parseInt(this.state.state.reference)})
    };
  
    renderBarcodeReader = () =&gt; {
      const { hasCameraPermission, scanned } = this.state;
  
      if (hasCameraPermission === null) {
        return &lt;Text&gt;{i18n.t(&quot;scan.request&quot;)}&lt;/Text&gt;;
      }
      if (hasCameraPermission === false) {
        return &lt;Text&gt;{i18n.t(&quot;scan.noaccess&quot;)}&lt;/Text&gt;;
      }
      return (
        &lt;View
          style={{
            flex: 1,
            ...StyleSheet.absoluteFillObject
          }}
        &gt;   
        &lt;Camera
          onBarCodeScanned={scanned ? undefined : this.handleBarCodeScanned}
          barCodeScannerSettings={[Camera.Constants.Type.qr]}
          style={{flex:1}}
        /&gt;
          {scanned &amp;&amp; (
            &lt;Button
              title={&quot;Tap to Scan Again&quot;}
              onPress={() =&gt; this.setState({ scanned: false })}
            /&gt;
          )}    
        &lt;/View&gt;
      );
    }
    handleSelectItem(item, index) {
      const {onDropdownClose} = this.props;
      onDropdownClose();
      console.log(item);
    }
    render() {
      const { hasCameraPermission, scanned, Press } = this.state;
      let marker = null;
  
      const {scrollToInput, onDropdownClose, onDropdownShow} = this.props;
  
   console.log('displayArray', this.state.displayArray, 'reference', this.state.displayArray.name)
  
      return (
        &lt;View style={{flex:1}}&gt;
          &lt;Text style={{zIndex:100, color: 'red', fontStyle: 'italic', fontSize: 14}}&gt;{i18n.t(&quot;tickets.warning&quot;)}&lt;/Text&gt; 
          &lt;View style={{width: &quot;100%&quot;, zIndex: 100}}&gt;                         
            &lt;Autocomplete
              key={shortid.generate()}
              containerStyle={{margin: 0, padding: 0, borderBottomColor: 'transparent',}}
              inputStyle={{ width: '80%', borderWidth: 1, backgroundColor: '#FFF', opacity: 0.9, borderColor: '#F78400'}}
              placeholder={i18n.t(&quot;tickets.event&quot;)}
              placeholderColor=&quot;#F78400&quot;
              pickerStyle={styles.autocompletePicker}
              scrollStyle={styles.autocompleteScroll}
              scrollToInput={ev =&gt; {}}
              handleSelectItem={(item, id) =&gt; this.handleSelectItem(item, id)}
              onDropdownClose={() =&gt; onDropdownClose()}
              onDropdownShow={() =&gt; onDropdownShow()}              
              fetchDataUrl={Api}
              minimumCharactersCount={2}
              highlightText
              valueExtractor={item =&gt; item.name}
              rightContent
              rightTextExtractor={item =&gt; item.properties}
            /&gt;
          &lt;/View&gt;
            {this.renderBarcodeReader()}                 
        &lt;/View&gt;
      );
    }
  }
  export default Tickets;
  </code></pre>