Questions tagged [react-native-image-picker]

This package is the basic package by react native community to upload an image from your gallery or camera.

This is the way it opens on click in iOS

This way it opens in android on a click

A React Native module that allows you to use native UI to select a photo/video from the device library or directly from the camera. You have to specify both permission of accessing camera and gallery in both platforms(android and iOS).

A code snippet to simplify:

import ImagePicker from 'react-native-image-picker';

// More info on all the options is below in the API Reference... just some common use cases shown here
const options = {
  title: 'Select Avatar',
  customButtons: [{ name: 'fb', title: 'Choose Photo from Facebook' }],
  storageOptions: {
    skipBackup: true,
    path: 'images',
  },
};

/**
 * The first arg is the options object for customization (it can also be null or omitted for default options),
 * The second arg is the callback which sends object: response (more info in the API Reference)
 */
ImagePicker.showImagePicker(options, (response) => {
  console.log('Response = ', response);

  if (response.didCancel) {
    console.log('User cancelled image picker');
  } else if (response.error) {
    console.log('ImagePicker Error: ', response.error);
  } else if (response.customButton) {
    console.log('User tapped custom button: ', response.customButton);
  } else {
    const source = { uri: response.uri };

    // You can also display the image using data:
    // const source = { uri: 'data:image/jpeg;base64,' + response.data };

    this.setState({
      avatarSource: source,
    });
  }
});

Then later, you can display this image in your render() method.

304 questions
-1
votes
2 answers

Render fileName using image-picker in react-native

I am using react-native-image-picker I want to render the fileName which I got in it's response. Any ideas?
user11426267
  • 361
  • 4
  • 7
  • 13
-1
votes
1 answer

React Native ImagePicker.launchImageLibrary not work, the app close instead of the picking an image

I have react-native-image-picker in my app. If i'm calliing ImagePicker.launchImageLibrary the app is closing instead of the opening of the gallery. And the same behavior is happening when i call ImagePicker.showImagePicker and after Choose from…
jocoders
  • 1,594
  • 2
  • 19
  • 54
-1
votes
1 answer

react-native link react-native-image-picker throws "(assets || []).map is not a function" error

I get the following issues when I attempt to add react-native-image-picker to my project. $ npm install react-native-image-picker --save npm WARN @babel/plugin-check-constants@7.0.0-beta.38 requires a peer of @babel/core@7.0.0-beta.38 but none is…
-1
votes
1 answer

What files determine the app size of a react native app?

I want to make sure I am creating my file system properly for my react native app. Currently, I receive images on the app from the user, and then I save them in an images folder within the project. The file system's structure looks like…
1 2 3
20
21