search

Home  >  Q&A  >  body text

Problem react-zxing switching problem: camera cannot be turned off

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粉465675962P粉465675962280 days ago459

reply all(1)I'll reply

  • P粉608647033

    P粉6086470332024-03-22 12:13:55

    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
    });

    reply
    0
  • Cancelreply