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

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

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745468915a4629041.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信