The react image picker is working but this is what happens.
Once I click on the “Select an image button” → the popup comes up → then I am supposed to be able to select an image from the popup which shows all the images in the popup in the image library →
I try to keep pressing on the image and then select it (as shown on the image) → once I select, nothing happens, the screen remains on the popup and I am also not getting the image object returned function.
I will leave the code below, please someone help with this problem. I am not able to move forward without resolving this error. Thanks.
Code
import React, { useEffect, useState } from “react”;
import { View, Text, SafeAreaView, Image, Button } from “react-native”;
import Screen from “./app/components/Screen”;
import * as ImagePicker from “expo-image-picker”;
import * as Permissions from “expo-permissions”;
import { TouchableOpacity } from “react-native-gesture-handler”;
import ImageInput from “./app/components/ImageInput”;
export default function App() {
const [imageUri, setImageUri] = useState();
const requestPermissions = async () => {
const { granted } = await ImagePicker.requestMediaLibraryPermissionsAsync();
if (!granted) {
alert(“You need to allow permissions to access the library”);
}
};
const selectImage = async () => {
console.log(“i am here”);
const result = await ImagePicker.launchImageLibraryAsync();
setImageUri(result.uri);
console.log(result);
};
console.log(“here”);
useEffect(() => {
requestPermissions();
}, []);
return (
<TouchableOpacity onPress={() => selectImage}>
<Image source={{ uri: imageUri }} style={{ width: 200, height: 200 }} />
<ImageInput imageUri={imageUri} />
</Screen>
);
}
import React, { useEffect, useState } from “react”;
import { View, Text, SafeAreaView, Image, Button } from “react-native”;
import Screen from “./app/components/Screen”;
import * as ImagePicker from “expo-image-picker”;
import * as Permissions from “expo-permissions”;
import { TouchableOpacity } from “react-native-gesture-handler”;
import ImageInput from “./app/components/ImageInput”;
export default function App() {
const [imageUri, setImageUri] = useState();
const requestPermissions = async () => {
const { granted } = await ImagePicker.requestMediaLibraryPermissionsAsync();
if (!granted) {
alert(“You need to allow permissions to access the library”);
}
};
const selectImage = async () => {
console.log(“i am here”);
const result = await ImagePicker.launchImageLibraryAsync();
setImageUri(result.uri);
console.log(result);
};
console.log(“here”);
useEffect(() => {
requestPermissions();
}, []);
return (
<TouchableOpacity onPress={() => selectImage}>
<Image source={{ uri: imageUri }} style={{ width: 200, height: 200 }} />
<ImageInput imageUri={imageUri} />
</Screen>
);
}
Code