React-native-document-picker: undefined is not an object (evaluating '_reactnative document picker.document picker.show') Android

Created on 4 Oct 2018  路  14Comments  路  Source: rnmods/react-native-document-picker

screenshot_1538651436

even after linking. this error shows up in android and ios

DocumentPicker.show({
filetype: [DocumentPickerUtil.allFiles()],
},(error,res) => {
// Android
console.log(
res.uri,
res.type, // mime type
res.fileName,
res.fileSize
);
//this.setState({ image: res.uri });
});

Most helpful comment

Please update if you find any solution or any other path altogether @boerdjamin

All 14 comments

same problem here

Please update if you find any solution or any other path altogether @boerdjamin

I haven't solved/linked it successful yet, but I think it's the same issue like in https://github.com/react-community/react-native-image-picker/issues/269.

i have linked properly but i am using expo and maybe thats why its not working?

I checked by creating a new project without expo and it works fine. so i guess its not working with expo
@boerdjamin

Is there a way to make it work with Expo ?

@animeshjn
You can use expo鈥檚 documentpicker

i used without expo still this error occured

Any update on this ?

no update and no fix != closed :-/

same error here . im getting frustrate of reat-native. i thing is time to go back to android/kotlin

i had my to work thanks to this post
https://stackoverflow.com/questions/58300886/react-native-document-picker-type-error-undefined-document-picker-while-calli
i also use the new funtion pick instead of show
DocumentPicker.pick

If you are using v3+. You need to update your code from
DocumentPicker.show to DocumentPicker.pick.

import DocumentPicker from 'react-native-document-picker';

// Pick a single file
try {
const res = await DocumentPicker.pick({
type: [DocumentPicker.types.images],
});
console.log(
res.uri,
res.type, // mime type
res.name,
res.size
);
} catch (err) {
if (DocumentPicker.isCancel(err)) {
// User cancelled the picker, exit any dialogs or menus and move on
} else {
throw err;
}
}

i had my to work thanks to this post
https://stackoverflow.com/questions/58300886/react-native-document-picker-type-error-undefined-document-picker-while-calli
i also use the new funtion pick instead of show
DocumentPicker.pick

Worked for me. Thanks

Was this page helpful?
0 / 5 - 0 ratings