at first it worked but after refreshed it throwed error:- Please attach a method to this component
const imagePicker = async () => {
const permissionResult = await ImagePicker.requestMediaLibraryPermissionsAsync(
{ mediaType: ImagePicker.MediaTypeOptions.Images, quality: 10 }
);
if (permissionResult.granted === false) {
alert("Permission to access gallery is required!");
return;
}
const pickerResult = await ImagePicker.launchImageLibraryAsync();
if (pickerResult.cancelled === true) {
return;
}
setImage({ localUri: pickerResult.uri });
};