import type { Camera, PhotoFile } from 'react-native-vision-camera'; type HandleCapturePreviewProps = { cameraRef: React.RefObject; }; export type PreviewImage = { image: PhotoFile; path: string; }; type HandleCapturePreviewResult = Promise; export const handleCapturePreview = async ({ cameraRef, }: HandleCapturePreviewProps): HandleCapturePreviewResult => { if (cameraRef.current) { const image = await cameraRef.current.takeSnapshot({ quality: 100, }); const path = 'file://' + image.path; return { image, path, }; } throw new Error('CameraRef is not initialized'); }; export default handleCapturePreview;