expo-image-picker-hook
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

npm TypeScript PRs Welcome npm

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>
  )
}

📰 Changelog

Readme

Keywords

none

Package Sidebar

Install

npm i expo-image-picker-hook

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

10.4 kB

Total Files

6

Last publish

Collaborators

  • srbrahma