react-native-vision-camera
Version:
VisionCamera is the fastest and most powerful Camera for react-native.
16 lines (13 loc) • 466 B
text/typescript
import { useEffect } from 'react'
import type { CameraController } from '../../specs/CameraController.nitro'
import type { TorchMode } from '../../specs/common-types/TorchMode'
export function useTorchModeUpdater(
controller: CameraController | undefined,
torchMode: TorchMode | undefined,
): void {
useEffect(() => {
if (controller == null) return
if (torchMode == null) return
controller.setTorchMode(torchMode)
}, [controller, torchMode])
}