0

I am quite new to RN . I know this question is being repeated but I didn't quite get ans I was looking for there . So my current project uses expo for web and react-native cli for the android set up . I want to add an image-picker to the project. I see two options at my side .

  1. RN-image-picker
  2. expo-image-picker

I have some issues and some questions !!

  1. Is RN-native-image picker comaptible with web ??
    • I think its not ,there are two resons I think that ,this lib uses Nativemodules, which won't be bundled for web and its giving undefined error for NativeModules when I run with web while it works fine on android .
  2. Should I use expo-image-picker when I am creating a android build with react-native cli ??
  • The build doesn't give errors and it shouldn't ,but when I click on upload image ,app crashes after I select image.I read the docs and github for the issue.Many people pointed out its ram allocation issue,which can be sorted with disbaling "Dont keep activities" in developer's option,which I haven't tried yet .
  1. Also on web ,the following code snippet returns base64 as uri,is it default behaviour ??

I am using this code snippet for expo-image-picker,which ends up crashing app when I build app with rn cli,but doesn't seem to cause issues with expocli build.But I want to use expo for web and rn for android. Also on web ,the following code snippet returns base64 as uri,is it default behaviour ??

const pickImage = async () => {
        try{
        let result = await ImagePicker.launchImageLibraryAsync({
            mediaTypes: ImagePicker.MediaTypeOptions.Images,
            allowsEditing: true,
            aspect: [4, 3],
            quality: 1,
            base64:false
        })
         if(!result.isCancelled)return result.uri ;
    }catch(err){
        console.log(err) ;
    }
       
 }

So what should I do in this case,use expo-image-picker as it seems to be compatible with all platforms/both ? Any kind of input would be helpful !!

Kunal Solanke
  • 48
  • 1
  • 7

1 Answers1

1

I'm not a fan of Expo, and I don't have experience with that but I try to answer to your question that can be.

Is RN-native-image picker comaptible with web ??

You have right, the library supports only mobile devices.

Should I use expo-image-picker when I am creating an android build with react-native cli ??

From expo documentation, I read that but I know also that sometimes the rn-cli and expo has some package differences, and this answer proves that.

Expo never locks you in, you can "eject" at any time and your project will just be a typical native project with the React Native and Expo SDK packages that your app is using installed and configured.

I don't know what the exception, and maybe the solution that you put in your answer work well, but maybe is possible to have some dependency mismecc? Such as a none object on the Web app? or something like that.

Also on web ,the following code snippet returns base64 as uri,is it default behaviour ??

This looks like be an bug and this issue on github maybe can confirm my idea

vincenzopalazzo
  • 1,487
  • 2
  • 7
  • 35