import React, { useRef } from 'react'; import { View, TouchableOpacity, Text } from 'react-native'; import { RNCamera } from 'react-native-camera'; import RNFS from 'react-native-fs'; const CameraScreen = () => { const cameraRef = useRef(null); const takePicture = async () => { if (cameraRef.current) { const options = { quality: 0.5, base64: true }; const data = await cameraRef.current.takePictureAsync(options); // Save the image to the gallery saveToGallery(data.uri); } }; const saveToGallery = async (imageUri) => { try { const destinationPath = RNFS.CachesDirectoryPath + '/myImage.jpg'; // Copy the image file to the gallery await RNFS.copyFile(imageUri, destinationPath); // Notify the gallery about the new file RNFS.scanFile(destinationPath); } catch (error) { console.error('Error saving image to gallery:', error); } }; return ( Take Picture ); }; export default CameraScreen;