Problem react-zxing switching problem: camera cannot be turned off
P粉465675962
P粉465675962 2024-03-21 22:57:34
0
1
458

I'm using react-zxing to scan barcodes on a web page.

I have two options for scanning the barcode,

  1. Use zxing library to scan barcode and
  2. Manually enter the barcode.

question:

  1. If I switch to "Manual Input Mode" and then switch back to "Scan Mode", the scan view disappears.
  2. If I switch to "Manual Input Mode" the camera does not turn off. (On my laptop, there is a camera light that lights up if the camera is in use)

Real-time code

You can see the live code: https://codesandbox.io/s/suspicious-jerry-1jr2xx?file=/src/App.js

P粉465675962
P粉465675962

reply all(1)
P粉608647033

Try to add paused in the options of useZxing. The camera will stop when manualInput is true.

const { ref } = useZxing({
  onResult(result) {
    setResult(result.getText());
  },
  paused: manualInput
});
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template