UNPKG

react-native-vision-camera

Version:

VisionCamera is the fastest and most powerful Camera for react-native.

25 lines (24 loc) 880 B
import { useEffect, useMemo } from 'react'; export function useCameraControllerConfiguration(controller, config) { const memoizedConfig = useMemo(() => ({ enableDistortionCorrection: config.enableDistortionCorrection, enableLowLightBoost: config.enableLowLightBoost, enableSmoothAutoFocus: config.enableSmoothAutoFocus, }), [ config.enableDistortionCorrection, config.enableLowLightBoost, config.enableSmoothAutoFocus, ]); useEffect(() => { if (controller == null) return; if (Object.values(memoizedConfig).every((v) => v == null)) { // all props are null, we can skip the configuration. return; } const load = async () => { await controller.configure(memoizedConfig); }; load(); }, [memoizedConfig, controller]); }