Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

barcodeRead is always false even after scanning #43

Closed
IngyuTae opened this issue Jan 31, 2020 · 7 comments
Closed

barcodeRead is always false even after scanning #43

IngyuTae opened this issue Jan 31, 2020 · 7 comments
Labels
bug Something isn't working released

Comments

@IngyuTae
Copy link

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
@IngyuTae
Copy link
Author

IngyuTae commented Jan 31, 2020

one more issue found, it scans not only qrcode but all barcode types despite barcodeTypes prop.

@nartc
Copy link
Owner

nartc commented Jan 31, 2020

@taeingyu It would be helpful if you could share a minimal reproducible repo. If not, it would just take a little longer for me to reproduce it. Regarding the Barcode issue, that would be RNCamera issue. This library is just a Finder area Mask that really does not dictate how the Camera module actually works. Have you tried looking at the Issues on react-native-camera for the barcodeTypes issue?

Thanks for reporting the issue. Just a headsup, I'm going to participate in a local Game Jam this weekend so I might not be able to look into this for couple of days.

@IngyuTae
Copy link
Author

IngyuTae commented Jan 31, 2020

@nartc Thanks for quick reply, this is the reproducible repo https://github.com/taeingyu/react-native-barcode-mask-example only for iOS. Unfortunately without BarcodeMask component it works fine.

@nartc
Copy link
Owner

nartc commented Jan 31, 2020

@taeingyu Thanks. I'll take a look as soon as I have a chance.

@nartc nartc added the bug Something isn't working label Jan 31, 2020
@nartc nartc closed this as completed in f90baa9 Feb 6, 2020
@nartc
Copy link
Owner

nartc commented 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.

@nartc
Copy link
Owner

nartc commented Feb 6, 2020

🎉 This issue has been resolved in version 1.1.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@nartc nartc added the released label Feb 6, 2020
@IngyuTae
Copy link
Author

IngyuTae commented Feb 7, 2020

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

It works great! and the new barcodeReadDelay is just the feature I was looking for. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

No branches or pull requests

2 participants