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

torch prop not work #18

Open
DavidRojas1612 opened this issue Aug 18, 2021 · 7 comments
Open

torch prop not work #18

DavidRojas1612 opened this issue Aug 18, 2021 · 7 comments
Labels
documentation Improvements or additions to documentation

Comments

@DavidRojas1612
Copy link

I am trying to use the torch prop in my implementation, but I can't get this to work,

const [torch, setTorch] = useState(false);

return (
...
<i className={`icon-Icon_torch ${styles.torch}`} onClick={() => setTorch(prev => !prev)} />
<BarcodeScannerComponent
  width="100%"
  height={
    windowSize.height
      ? windowSize.height - SCAN_CONFIG.footerHeight
      : SCAN_CONFIG.cameraDefaultHeight
  }
  torch={torch}
  facingMode="environment"
  onUpdate={(err, result) => {
    if (result) {
      handleResult(result.getText());
    }
  }}
/>
@sksurendrakmr
Copy link

torch props are working fine.
It will only work if flashlight or torch is available in device otherwise not.

@franciscopantojag
Copy link

franciscopantojag commented Jul 23, 2022

Hello @sksurendrakmr, do you know of any examples where the react-qr-barcode-scanner is opened and the flashlight is on? If that's the case, can you please provide one? Thanks in advance!

@ZaimSa
Copy link

ZaimSa commented Aug 25, 2022

I had the same problem when I tried to set the value to true directly, to work around the problem you have to use a state variable and add a timeout: setTimeout(()=>{setTorchOn(!torchOn)}, 1500 );

@morkeleb
Copy link

I can't get the torch to work on an IPhone 13 nor 14. We're setting the torch property similarly to what @DavidRojas1612 wrote above

@jiaxiangcheng
Copy link

I can't get the torch to work on an IPhone 13 nor 14. We're setting the torch property similarly to what @DavidRojas1612 wrote above

On my iphone 13 the torch has no effect, but facingMode it is working

@donburks
Copy link

donburks commented Sep 2, 2023

Also cannot get torch to work on iPhone 13.

@donburks
Copy link

donburks commented Sep 2, 2023

I had the same problem when I tried to set the value to true directly, to work around the problem you have to use a state variable and add a timeout: setTimeout(()=>{setTorchOn(!torchOn)}, 1500 );

Can you provide a bit more sample code of how you did this, please?

@jamenamcinteer jamenamcinteer added help wanted Extra attention is needed hacktoberfest documentation Improvements or additions to documentation and removed help wanted Extra attention is needed hacktoberfest labels Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

8 participants