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
vote
0 answers

How to use react-native-image-picker with Redux in React-native

I'am trying to use react-native-image-picker function inside the reducer to change the avatar but the image is not changing. i can solve this by writing the image picker function inside the avatar.js file but i want to use this way. if anyone knows…
Soufiane Odf
  • 1,054
  • 2
  • 9
  • 23
1
vote
0 answers

Getting error during uploading a video in react native

I am fetching video from mobile using react-native-image-picker and uploading it to the server by using the fetch method. Don't know what I am doing wrong? constructor(props){ super(props); this.state = { isLoading:true, isModalVisible:…
Mayuresh Patil
  • 2,072
  • 1
  • 21
  • 44
1
vote
1 answer

React Native image picker is showing image too slow after successfully uploading

after uploading image successfully the uploaded image is taking time to show ? anyone knows anything about it? here is my code _onPressEdit = () => { ImagePicker.showImagePicker(options, response => { console.log('Response = ',…
Syed Amir Ali
  • 873
  • 12
  • 22
1
vote
1 answer

How to copy images from gallery to app’s installation directory in React-native

I want to pick an image from gallery and copy that image to the currently running app’s installation directory using react-native.
1
vote
2 answers

React Native Expo How to upload an image to Firebase using expo Image picker

I'm trying to upload an Image to my firebase but I can't figure it out. This is my code _pickImage = async () => { let result = await ImagePicker.launchImageLibraryAsync({ mediaTypes: ImagePicker.MediaTypeOptions.All, …
1
vote
1 answer

[Unhandled promise rejection: TypeError: null is not an object (evaluating '_reactNativeImageCropPicker.default.openPicker')]

I am running my react-native app through the expo. The same thing is happening with react-native-image-picker. I tried using react-native link react-native-image-picker and react-native link react-native-image-crop-picker. It didn't work, so I tried…
1
vote
1 answer

Using react-native image picker requires 2 permissions- 1 is camera. And Google playstore requires a privacy statement for using camera

I use RN-ImagePicker library. But, i use it only for picking images from external storage. But, this library doesn't work without both the permissions. 1 is camera and other one is storage. Google play console wont let me upload the apk. Saying,…
1
vote
0 answers

Customise style of image select react native image picker

How do you change the colour of the react-native-image-picker choose from library screen? I have added the following to styles.xml