最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - TypeError: Cannot read property 'launchImageLibrary' of null - Stack Overflow

programmeradmin1浏览0评论

I have tried all the solutions online for this error. I am unable to open the image gallery.

<Button
    onPress={() =>
      ImagePicker.launchImageLibrary(
       {
        mediaType: 'photo',
        includeBase64: false,
        maxHeight: 200,
        maxWidth: 200,
       },
        response => {
           console.log(response);
           setPhoto(response);
          },
        )
     }
       title="Select Image"
/>

Solutions I have tried:

rm -rf node_modules
npm install
cd ios
pod install
cd ..

tried to change the import and how I call the launchImageLibrary

import * as ImagePicker from 'react-native-image-picker';
// import {launchImageLibrary} from 'react-native-image-picker';

Unfortunately I have not found a solution that works? Any ideas?

I have tried all the solutions online for this error. I am unable to open the image gallery.

<Button
    onPress={() =>
      ImagePicker.launchImageLibrary(
       {
        mediaType: 'photo',
        includeBase64: false,
        maxHeight: 200,
        maxWidth: 200,
       },
        response => {
           console.log(response);
           setPhoto(response);
          },
        )
     }
       title="Select Image"
/>

Solutions I have tried:

rm -rf node_modules
npm install
cd ios
pod install
cd ..

tried to change the import and how I call the launchImageLibrary

import * as ImagePicker from 'react-native-image-picker';
// import {launchImageLibrary} from 'react-native-image-picker';

Unfortunately I have not found a solution that works? Any ideas?

Share Improve this question asked Jun 18, 2023 at 17:05 JasonBeedleJasonBeedle 4897 silver badges19 bronze badges 1
  • The fix was to ``` rm -rf node_modules npm install cd ios pod install cd .. ``` Then clean the build and rebuild the app. – JasonBeedle Commented Jun 18, 2023 at 20:20
Add a ment  | 

3 Answers 3

Reset to default 3

The fix was to

rm -rf node_modules 
npm install 
cd ios 
pod install 
cd ..

Then clean the build and rebuild the app.

My temporary solution after updating to Android SDK 33 is to upgrade react-native-image-picker to version 5.0.0 and use react-native-permissions package to handle READ_MEDIA_IMAGES permission.

You could stop the server and run the App with

react-native start --reset-cache.

So you don't have to reinstall all your modules.

发布评论

评论列表(0)

  1. 暂无评论