I'm using Image Picker to get the user photo and then I need to show it in the next screen. How can i achieve this?
Image Picker function:
const options={
title: 'Profile picture',
takePhotoButtonTitle: 'Take picture',
chooseFromLibraryButtonTitle: 'Choose from gallery'
}
myFun=()=>{
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 };
// You can also display the image using data:
// const source = { uri: 'data:image/jpeg;base64,' + response.data };
this.setState({
avatarSource: source,
});
}
});
}
I need to pass the image to the next screen with this button:
<GradientButton text='Next' onPress={() => {this.props.navigation.navigate('NextScreen', {photo: this.state.avatarSource} )}}/>
This is how I was trying but I can't make it work, I only managed to pass normal values like Strings with navigate parameters.