Skip to content

DocumentPicker.show() is not working with "react-native": "0.59.1" #228

Closed

Description

@Pratyanch-7415

I am getting this error:
"undefined is not an object (evaluating '_reactNativeDocumentPicker.DocumentPicker.show')".

Please suggest the best suitable solution.
Thanks in advanced

Activity

  1. SnehalAgrawal commented on Aug 17, 2019

    @SnehalAgrawal

    @Pratyanch-7415 react-native-document-picker version?

  2. grwimran commented on Aug 23, 2019

    @grwimran

    Same Problem with RN 0.60 and react-native-document-picker 3.2.4 .
    Any Help Please

  3. SnehalAgrawal commented on Aug 23, 2019

    @SnehalAgrawal

    Library has been updated and now DocumentPicker.show() has been changed and also updated the support to pick multiple Document as well.
    Now to pick single document

    try {
      const res = await DocumentPicker.pick({
        type: [DocumentPicker.types.allFiles],
      });
      this.setState({ singleFile: res });
    } catch (err) {
      if (DocumentPicker.isCancel(err)) {
        //If user canceled the document selection
      } else {
        //For Unknown Error
        throw err;
      }
    }
    

    To pick multiple document

    try {
      const results = await DocumentPicker.pickMultiple({
        type: [DocumentPicker.types.images],
      });
      for (const res of results) {
        console.log('res : ' + JSON.stringify(res));
      }
      this.setState({ multipleFile: results });
    } catch (err) {
      if (DocumentPicker.isCancel(err)) {
        //If user canceled the document selection
      } else {
        //For Unknown Error
        throw err;
      }
    }
    

    If you are still confused then you can see Example of File Picker in React Native. You will find how to integrated the Document picker for React Native 0.60 and the updated post.

  4. grwimran commented on Aug 27, 2019

    @grwimran
  5. grwimran commented on Aug 27, 2019

    @grwimran
  6. grwimran commented on Aug 27, 2019

    @grwimran
  7. dantman commented on Aug 27, 2019

    @dantman
    Collaborator

    @grwimran Please update your import to import DocumentPicker from 'react-native-document-picker';, that error suggests you are importing import {DocumentPicker} from 'react-native-document-picker'; which is undefined.

  8. SnehalAgrawal commented on Aug 27, 2019

    @SnehalAgrawal

    @grwimran This is because you haven't linked the library or have import issue that is why it is unable to find DocumentPicker. Please link the library or check the import and try again.
    Here is a step by step example please go through it https://aboutreact.com/file-picker-in-react-native/

  9. grwimran commented on Aug 27, 2019

    @grwimran
  10. SnehalAgrawal commented on Aug 27, 2019

    @SnehalAgrawal

    Can you please check for this
    #228 (comment)

  11. grwimran commented on Aug 27, 2019

    @grwimran

    Thanx Done

  12. MaximilianoRG commented on Sep 9, 2019

    @MaximilianoRG

    Try this:

    1. Don't put lib(Project)DocumentPicker.a on Build Phases.

    2. Change the order of Link binary with Libraries and Copy Boundle Resources in this order:

      • Copy Boundle Resources
      • Link binary with Libraries

    When i did this. It worked.

  13. locked and limited conversation to collaborators on Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions