Unhandled Promise Rejection (id:0) ImagePicker


#1

I am trying to use ImagePicker but I keep getting this warning and nothing works.
My Code

export const uploadFromGallery =  function (){    
    return new Promise(async function(resolve, reject){
        var result = await ImagePicker.launchImageLibraryAsync({
            allowsEditing: true, 
            aspect: [4,3]
        });
        console.log(result)
        if(!result.cancelled){
            resolve(result.uri)
        }
        else
            reject(error)
    })
}

Error:

Possible Unhandled Promise Rejection (id: 0):
TypeError: undefined is not a function (evaluating '_expo2.default.launchImageLibraryAsync')


#2

How are you importing ImagePicker? You probably want something like this:

import Expo, { ImagePicker } from 'expo';


#3

no. I am importing it like

import ImagePicker from 'expo'

The thing is I was creating a util.js where I am coding all the camera related functions and then importing it on various other screens. Calling it directly works. But when I am trying to code the funtion somewhere and import it, it throws this error


#4

Were you able to resolve this issue?