Skip to content
This repository has been archived by the owner on May 12, 2023. It is now read-only.

Keeps repeating scanning same qr code multiple times #406

Open
ZAT90 opened this issue Jan 31, 2023 · 2 comments
Open

Keeps repeating scanning same qr code multiple times #406

ZAT90 opened this issue Jan 31, 2023 · 2 comments

Comments

@ZAT90
Copy link

ZAT90 commented Jan 31, 2023

When scanning a QR code, it keeps on repeating the scan process. As a result, it keeps giving the same result multiple times as well and keep on vibrating.

What's happening?

When scanning a QR code, if the camera is kept pointed at the qr code, it keeps on scanning for multiple times

How can it be reproduced?

Keep the camera pointed at a specific QR code and do not move the phone

Build details?

1.4.1

@ZAT90 ZAT90 changed the title Keep scanning same qr code multiple times Keeps repeating scanning same qr code multiple times Jan 31, 2023
@ZAT90
Copy link
Author

ZAT90 commented Feb 3, 2023

have tried with latest version 1.5.5, still the same. Any idea @moaazsidat ?

@BraveEvidence
Copy link

@Yukesh2412
Copy link

When scanning a QR code, it keeps on repeating the scan process. As a result, it keeps giving the same result multiple times as well and keep on vibrating.

What's happening?

When scanning a QR code, if the camera is kept pointed at the qr code, it keeps on scanning for multiple times

How can it be reproduced?

Keep the camera pointed at a specific QR code and do not move the phone

Build details?

1.4.1

Hi, I have a possible solution for this issue. You can use a debounce function to limit the number of calls to the onBarCodeRead method and Please let me know if it solves your problem. Here is the code:

// Import debounce from lodash
import debounce from 'lodash.debounce';

// Define your onBarCodeRead function
const onBarCodeRead = (event) => {
  // Do something with the event object
  console.log(event.type, event.data);
};

// Define a debounced version of your onBarCodeRead function using React.useCallback hook
const debouncedOnBarCodeRead = React.useCallback(debounce(onBarCodeRead, 1000), []);

// Pass the debouncedOnBarCodeRead function as a prop to the QRCodeScanner component
<QRCodeScanner onBarCodeRead={debouncedOnBarCodeRead} />```

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants