I want to create an image grid like this one but I have failed to get camera roll from the device. I have tried using @react-native-community/cameraroll but it doesn t seem to work Here is my code.
import React,{useState, useEffect} from react ;
import {View} from react-native ;
import * as Permissions from expo-permissions ;
import CameraRoll from "@react-native-community/cameraroll";
const getImages = async (setImages) => {
await Permissions.askAsync(Permissions.CAMERA_ROLL);
const x=await CameraRoll.getPhotos({first:2})
await setImages([...x.edges])
}
export default function App() {
const [images,setImages]=useState([])
useEffect(() => {
console.log( loading photos )
getImages(setImages)
console.log( back )
console.log(images)
}, []);
return (
<View >
</View>
);
}
The code is intended to load images into the state when the component mounts. How can I fix this problem?