question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

barcodeRead is always false even after scanning

See original GitHub issue

To Reproduce

import React, { useRef, useCallback } from 'react';
import { View, StyleSheet } from 'react-native';
import { RNCamera } from 'react-native-camera';
import { BarcodeMask, useBarcodeRead } from '@nartc/react-native-barcode-mask';

function CameraScreen({ navigation }) {
  const camera = useRef(null);

  const handleBarcodeData = useCallback(
    barcodeData => {
      console.log('barcodeData', barcodeData);
      // navigation.goBack();
    },
    [navigation],
  );

  const {
    barcodeRead,
    onBarcodeRead,
    onBarcodeFinderLayoutChange,
  } = useBarcodeRead(
    navigation.isFocused(),
    barcodeData => barcodeData,
    handleBarcodeData,
  );

  console.log('barcodeRead', barcodeRead);

  return (
    <View style={styles.container}>
      <RNCamera
        ref={camera}
        style={{
          flex: 1,
          width: '100%',
        }}
        captureAudio={false}
        onBarCodeRead={onBarcodeRead}
        barcodeTypes={barcodeRead ? [] : [RNCamera.Constants.BarCodeType.qr]}
      >
        <BarcodeMask
          onLayoutChange={onBarcodeFinderLayoutChange}
          maskOpacity={0.5}
          animatedLineColor="#f00"
        />
      </RNCamera>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});

export default CameraScreen;

Expected behavior console.log() message should be

                                                  (before scanning)
barcodeRead false
                                                  (after scanning)
barcodeData 1234
barcodeRead true
                                                  (stop)

However barcodeRead is always false, so it does not change barcodeTypes prop.

                                                  (before scanning)
barcodeRead false
                                                  (after scanning)
barcodeData 1234
barcodeRead false
barcodeData 1234
barcodeRead false
barcodeData 1234
barcodeRead false
...                                               (repeat)

Smartphone (please complete the following information):

  • Device: iPhone X
  • OS: iOS 13
  • react-native 0.61, react-native-camera 3.16
  • 1.1.6

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nartccommented, Feb 6, 2020

🎉 This issue has been resolved in version 1.1.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

1reaction
nartccommented, Feb 6, 2020

@taeingyu Please check out the latest release to see if it works out for you. Please read the README regarding barcodeRead changed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why Do Barcodes Misread?
Misreads in the form of a perfectly scanning but wrong barcode can be caused by scanner number substitution. The printed barcode image is ......
Read more >
Why Aren't My Barcodes Scanning? 3 Common Problems ...
If your scanner is neither old, nor set to read the incorrect barcode language, your issue may have to do with programming (or...
Read more >
Having Problems Reading Your Barcodes? Here's How to Fix It
Poor barcode/scanner position · The barcode might be too close or too far from the scanner, depending on the scanner's optimal focal distance...
Read more >
The Most Common Causes of Unreadable Barcodes
The most common causes of unreadable barcodes are low contrast, quiet zone violations, improper reading position, print or mark inconsistency, and damage or ......
Read more >
Barcode Scanner does not stop scanning · Issue #345 - GitHub
The scanner doesn't stop scanning even when a qr/bar code has already been detected. There should be a way to stop this.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found