Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is react-native-image-picker's showImagePicker undefined in React Native?

Currently I am running my React Native project via terminal and Atom editor. I am trying to use rect-native-image-picker from https://github.com/marcshilling/react-native-image-picker and followed the instructions to install: npm install react-native-image-picker@latest --save

And my dependencies show: "react-native-image-picker": "^0.22.8"

Then I tried following the exact example, yet I am still getting an error on ImagePicker.showImagePicker(options, (response) => {...}) when I press the button to choose an image: Cannot read property 'showImagePicker' of undefined

So I console.log(ImagePicker) of import ImagePicker from 'react-native-image-picker', which is exactly how it is implemented in the Example project from react-native-image-picker, and it logged:

enter image description here

So I cloned the Example project and also console.log(ImagePicker) and it showed:

enter image description here

I am starting to believe that the issue is that I am not getting functions that I am supposed to get, such as launchCamera and launchImageLibrary. I can't seem to figure out why. What could I be missing or doing incorrectly?

like image 401
Jo Ko Avatar asked Sep 27 '16 09:09

Jo Ko


2 Answers

What version of RN and iOS do you use? If you are sure that you linked npm package with native code (rnpm link), you can try add to your Info.plist (right key -> Open as source code) between <dict> tags:

<key>NSPhotoLibraryUsageDescription</key>
<string>This app requires access to the photo library.</string>
like image 97
jonzee Avatar answered Sep 20 '22 10:09

jonzee


I have also faced the same issue. So in the documentation, the auto-linking is given but it is not linking all the dependency. You need to link some dependency manually. Please follow this below link it will help you. For manually linking follow this

like image 31
Hemantkumar Gaikwad Avatar answered Sep 20 '22 10:09

Hemantkumar Gaikwad