react-native-vision-camera icon indicating copy to clipboard operation
react-native-vision-camera copied to clipboard

Open Flash light by click on the Icon

Open zoobibackups opened this issue 9 months ago • 4 comments

Question

how I open flash light when I click on Icon

What I tried

No response

VisionCamera Version

"react-native-vision-camera": "^4.0.1"

Additional information

zoobibackups avatar May 06 '24 10:05 zoobibackups

Question

how I open flash light when I click on Icon

What I tried

const toggleFlash =() => { cameraRef.current?.CameraDevice({ hasTorch: 'on' }) }

VisionCamera Version

"react-native-vision-camera": "^4.0.1"

Additional information

zoobibackups avatar May 06 '24 10:05 zoobibackups

Why not have a state variable for the torch?

bruno-centanaro avatar May 06 '24 23:05 bruno-centanaro

const [torch,setTorch] = useState(false); const toggleFlash =() => { cameraRef.current?.CameraDevice({ hasTorch: 'on', }) setTorch(!torch) } <Camera hasTorch={torch} ref={cameraRef} style={StyleSheet.absoluteFill} device={device} isActive={isActive} />

but error is that cameraRef.current.CameraDevice is not a function it is undefined

zoobibackups avatar May 07 '24 05:05 zoobibackups

but why is it not a prop of the camera component? With this So it should be something like torch={torch ? 'on' : 'off'}

bruno-centanaro avatar May 07 '24 12:05 bruno-centanaro