I'm trying to integrate react-native-image-picker and I was able to successfully install it. Now when I try to choose image from gallery in log it does shows that my imageSource has value but it doesn't display. I'm currently running it on iOS simulator. Below is my code
import ImagePicker from "react-native-image-picker";
const options = {
title: "Select a photo",
takePhotoButtonTitle: "Take a photo",
chooseFromLibraryButtonTitle: "Choose from gallery",
quality: 1
};
constructor(props) {
super(props);
this.state = { imageSource: null };
}
addImage = () => {
ImagePicker.showImagePicker(options, (response) => {
console.log('Response = ', response);
if (response.didCancel) {
console.log('User cancelled image picker');
} else if (response.error) {
console.log('ImagePicker Error: ', response.error);
} else {
const source = { uri: response.uri };
this.setState({
imageSource: source,
});
console.log("Imagesource=" + JSON.stringify(source));
}
});
}
render() {
return (
<View style={styles.container}>
<Image source={this.state.imageSource} />
</View>
);
}
The console log does print the path to the image I picked from gallery but it just doesn't display. I'm running it on iPad with landscape orientation. Any help is appreciated.