I am trying to set the state of an array, but it doesn't set it, I am mapping through the result of a fetch gotten from react-native-image-crop-picker , as i map I setState of the array but it doesn't set the state, it is always empty, after setting the state of the array I want to map through it and display it as an image, Please what may I be doing wrong, why isn't the array not getting set
import ImagePicker from 'react-native-image-crop-picker';
imageUpload(){
ImagePicker.openPicker({
multiple: true,
cropping: true,
mediaType: 'photo'
}).then(images => {
this.setState({
images_array: images.map(i => {
console.log('received image', i);
return {uri: i.path};
})
}, console.log(this.state.images_array));
}).catch(e => console.log(e));
}
constructor(props) {
super(props);
this.state = {
upload: false,
home: true,
category: false,
amount: false,
no: 0,
cat_id: '',
images_array: [],
description: '',
amount: '',
};
}
images = this.state.images_array.map((image, index)=>{
<Image resizeMode="contain" style={{width: 38,
height: 38,
borderRadius: 19}}
source={{uri: image.uri}}/>});
<ScrollView showsVerticalScrollIndicator={false}>
<Text style={{
fontFamily: 'mont-medium', fontSize: 14, color: '#000', marginTop: 39, textAlign: 'center' }}>
Upload at least one picture{'\n'} of your product
</Text>
<TouchableNativeFeedback onPress={this.imageUpload.bind(this)}>
<View style={styles.multi}>
<View style={{height: 111, width: 123,alignSelf: 'center',}}>
<Image
resizeMode="contain"
style={{alignSelf: 'center', flex: 1}}
source={require('../upload.png')}/></View>
<Text style={{fontFamily: 'mont', fontSize: 12,
color: '#b3b1b1',alignSelf: 'center',}}>
Attach photos...
</Text>
</View>
</TouchableNativeFeedback>
<View style={styles.does}>
{images}
</View>
</ScrollView>