简体   繁体   English

带 react-native 的切换手电筒(世博会)

[英]Toggle Flashlight with react-native (expo)

I am trying to toggle the flaslight from my react-native export app.我正在尝试从我的 react-native 导出应用程序中切换手电筒。 This Plugin does not work since I am using expo.这个插件不起作用,因为我使用的是 expo。

The flashMode property of the Expo Camera Component allows me to toggle the flash while taking a photo. Expo 相机组件的 flashMode 属性允许我在拍照时切换 flash。

Is there a way to toggle the flashlight in another way?有没有办法以另一种方式切换手电筒?

I ran into this same problem with expo .我在expo遇到了同样的问题。 What I did was expo ejected and then used this library to toggle the flash light ( https://www.npmjs.com/package/react-native-torch ).我所做的是弹出 expo 然后使用这个库来切换 flash 灯( https://www.npmjs.com/package/react-native-torch Then everything worked as it should然后一切正常

This solves the problem of using torch while scanning QRCode/BarCode in React Native (Expo) Project解决了React Native(Expo)项目中扫描二维码/条码时使用torch的问题

<Camera 
    flashMode={Camera.Constants.FlashMode.torch}
    barCodeScannerSettings={{
    barCodeTypes:[BarCodeScanner.Constants.BarCodeType.qr]
    }}
    onBarCodeScanned={handleBarCodeScanned}
    />

Preview预习

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM