admin管理员组文章数量:1318979
Currently I am running my React Native project via terminal and Atom editor. I am trying to use rect-native-image-picker from 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:
So I cloned the Example project and also console.log(ImagePicker)
and it showed:
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?
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./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:
So I cloned the Example project and also console.log(ImagePicker)
and it showed:
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?
-
Did you link the dependency?
rnpm link
– dting Commented Sep 27, 2016 at 9:17 -
@DTing sorry but what's that? In the terminal, project folder? I actually used react-native-image-picker for a previous project and installed and implmented it the exact same, and it worked then and don't recall doing the
rnpm link
. – Jo Ko Commented Sep 27, 2016 at 9:21 - See if following the rest of the instructions for the install section fixes your problem. github./marcshilling/react-native-image-picker#install – dting Commented Sep 27, 2016 at 9:27
- @DTing I'm wondering why it worked in my previous project by simply doing npm install, and the rest of the institutions apply to Xcode but I use a terminal and an editor for the project. – Jo Ko Commented Sep 27, 2016 at 9:44
- @DTing Please let me know if you had the chance to see my previous ment. – Jo Ko Commented Sep 27, 2016 at 19:21
4 Answers
Reset to default 1What 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>
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
Do this:
import {launchCamera, launchImageLibrary} from 'react-native-image-picker';
launchCamera(options, response => {
if (response.didCancel) {
console.log('User cancelled image picker');
} else if (response.error) {
alert('ImagePicker Error: ', response.error);
} else if (response.customButton) {
console.log('User tapped custom button: ', response.customButton);
} else {
alert(response.uri)
}
});
The reason is that ImagePicker.showImagePicker is depreciated
I'm not an expert but you can solved this issue thanks to :
- this tutorial showImagePicker https://dev-yakuza.posstree./en/react-native/react-native-image-picker/ & https://github./dev-yakuza/react-native-image-picker-example
- (!) I'm on React Native >= 0.60 but the react-native-image-picker version is "react-native-image-picker": "2.3.1"
- To use react-native-image-picker on iOS, open ios/[project name]/Info.plist and modify it like below.
I'm not an expert but you can solved this issue thanks to :
- this tutorial showImagePicker https://dev-yakuza.posstree./en/react-native/react-native-image-picker/ & https://github./dev-yakuza/react-native-image-picker-example
- (!) I'm on React Native >= 0.60 but the react-native-image-picker version is "react-native-image-picker": "2.3.1"
- To use react-native-image-picker on iOS, open ios/[project name]/Info.plist and modify it like below.
Don't hesitate to remove your nodes_modules and pod files then restart your server
Don't hesitate to remove your nodes_modules and pod files then restart your server
本文标签: javascriptWhy is reactnativeimagepicker39s showImagePicker undefined in React NativeStack Overflow
版权声明:本文标题:javascript - Why is react-native-image-picker's showImagePicker undefined in React Native? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742057135a2418365.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论