Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { mediaType = 'Images' } = this.props
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions[mediaType],
// mediaTypes: ImagePicker.MediaTypeOptions.All,
allowsEditing: mediaType === 'Images' ? true : false,
base64: true,
quality: 1,
});
if (!result.cancelled) {
const { onChangeCallback, input: { onChange } } = this.props
this.setState({ image: result.uri });
FileSystem.readAsStringAsync(result.uri, {
encoding: FileSystem.EncodingType.Base64
}).then((base64) => {
const res = { ...result, base64 }
onChangeCallback(res)
this.onToggleLoading()
})
.catch(error => {
console.error(error);
});
}
else {
this.onToggleLoading()
}
};