react-native-camera-kit
react-native-camera-kit copied to clipboard
Issue: Barcode Scanning Fails After Multiple Scans
I'm encountering an issue where the barcode scanner fails to read QR codes consistently after the second or third scan. It works fine initially, but after a few successful scans, the onReadCode event stops triggering, and the QR codes are no longer detected.
const onBarcodeScan = (event) => {
resetTimer();
cancelAlertToast();
const urlString = event?.nativeEvent?.codeStringValue;
if (!isScanningAllowed) {
return;
} else {
setScanningAllowed(false);
ProcessQrCode(urlString);
}}
{
isCameraActive && cameraPermission ? (
<View style={{ flex: 1 }}>
<Camera
ref={(ref) => (cameraRef.current = ref)}
flashMode="auto"
focusMode="off"
zoomMode="on"
style={[styles.camerascreen]}
torchMode={torchswitch}
cameraType={!cameraState ? CameraType.Back : CameraType.Front}
scanBarcode={true}
resizeMode="cover"
onReadCode={(event) => onBarcodeScan(event)}
/>
</View>
) : (
<View></View>
)
}
Expected behavior The scanner should consistently detect QR codes regardless of how many scans are performed.
Observed Behavior
- First scan works perfectly.
- Second or third scan starts failing randomly.
- onReadCode doesn’t trigger even when QR code is clearly visible.
Smartphone (please complete the following information):
- Device: Samsung Tab A
- OS: Android 10