barcodeRead is always false even after scanning
See original GitHub issueTo 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:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
🎉 This issue has been resolved in version 1.1.7 🎉
The release is available on:
Your semantic-release bot 📦🚀
@taeingyu Please check out the latest release to see if it works out for you. Please read the README regarding
barcodeRead
changed.