0
votes

I used react-native-image-picker for fetch image form camera and photo library. i follow the steps to and link react-native-image-picker in xcode. I will code also to open imagePicker. but have an error.

Note : I will used 0.46 for react native.

Successfully link in iOS and Android.

enter image description here

My Code :

import { ImagePicker } from 'react-native-image-picker'

And onButton :

handleImagePickUp = () =>{
   ImagePicker.launchImageLibrary(options, (response)  => {
   });
}

Error :

enter image description here

1
Where does this code break? When you press take photo/choose from library, or when calling the method which contains the given function? - Ryan Turnbull
the code break ImagePicker.launchImageLibrary. - Kirit Modi

1 Answers

1
votes

Instead of writing

import { ImagePicker } from 'react-native-image-picker',

you should declare ( In the same place )...

var ImagePicker = require('react-native-image-picker');.

The rest of your code should work, although it's hard to tell since its not provided. Hope this helps, if you dont understand why this must be done let me know.