expo-image-picker-hook
v1.1.0
Published
Convenient hook for expo-image-picker
Downloads
4
Readme
expo-image-picker-hook
Convenient hook for expo-image-picker
.
Supports blob
and base64
.
💿 Installation
expo install expo-image-picker-hook expo-image-picker
📖 Usage
function MyComponent() {
const ImagePicker = useImagePicker({
aspect: [2, 1],
quality: 0.9,
permissionNotGrantedText: 'You need to give the app permission to select the image.',
})
const pick = () => {
ImagePicker.pick()
.catch(err => Alert.alert('Error', err.message))
}
const upload = () => {
ImagePicker.upload({ fun: (image) => myApi.uploadImage(image) }, { mode: 'base64' })
.catch(err => Alert.alert('Error', err.message))
}
return (
<View>
<Image source={{ uri: ImagePicker.imageUri }}>
<Button onPress={pick}>
<Button onPress={upload} disabled={!ImagePicker.isPicked}>
</View>
)
}