IOS
After open the image picker and pick an image, the api will return promise, so in callback then() i can't setState(). Here is my following code.
showCamera() {
const ip = ImagePicker.openPicker({
maxWidth: 1000,
maxHeight: 1000,
includeBase64: true,
mediaType: 'photo',
cropping: true,
}).then(image => {
const { filename, mime, data } = image;
const source = `data:image/jpeg;base64,${data}`;
this.setState({
pic: source,
picType: mime,
picName: filename,
});
console.log(image, this.state);
});
}
It does not show any error, but warning. when i check back the state value, it was empty.

It suppose to set the state value. but it does'nt. im surprised nobody talking about this issue. Could be the way i did something is wrong or what. Please Advice~ Thanks You!
Alternative way are welcome~
ImagePicker.openPicker({
xxx
}).then(image => {
xxx
}).catch(err => {
console.log(err)
})
catch if there is something error
I found the problem! In my view got this
<TouchableOpacity onPress={this.showCamera}>
<Icon style={styles.icon} name='user' size={80} />
</TouchableOpacity>
i should change it to
this.showCamera.bind(this)
Most helpful comment
I found the problem! In my view got this
<TouchableOpacity onPress={this.showCamera}> <Icon style={styles.icon} name='user' size={80} /> </TouchableOpacity>i should change it to
this.showCamera.bind(this)