react-native-documents / document-picker

Document Picker for React Native

Home Page:https://react-native-documents.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Expo doesn't seem to work

sigmaSd opened this issue · comments

Problem: using any pick returns null, for example cannot read property 'pick' of undefined
same problem #221 #251 those issues are closed, but in the thread there are still user who still have this issue

Steps to reproduce:

  • npx create-expo-app app1
  • npx expo install react-native-document-picker

App.js

import { Pressable, Text } from 'react-native';
import * as DocumentPicker from 'react-native-document-picker'

export default function App() {
  const f = async () => {
    console.log(DocumentPicker.pickDirectory)
    console.log(await DocumentPicker.pickDirectory())
  }
  return (
    <Pressable onPress={f()}>
      <Text>Click Me</Text>
    </Pressable>
  );
}
  • npx expo start
  • connect on the server with android

Error happens

 LOG  [Function pickDirectory]
 WARN  Possible Unhandled Promise Rejection (id: 0):
TypeError: Cannot read property 'pickDirectory' of null
TypeError: Cannot read property 'pickDirectory' of null
    at ?anon_0_ (http://192.168.43.94:19000/node_modules/react-native-document-picker/src/index.bundle?platform=android&hot=false&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true:40:46)
    at next (native)
    at asyncGeneratorStep (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:4641:26)
    at _next (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:4660:29)
    at anonymous (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:4665:14)
    at tryCallTwo (/Users/kudo/01_Work/Repos/expo/expo/android/versioned-react-native/ReactAndroid/hermes-engine/.cxx/MinSizeRel/5a4n485h/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:61:9)
    at doResolve (/Users/kudo/01_Work/Repos/expo/expo/android/versioned-react-native/ReactAndroid/hermes-engine/.cxx/MinSizeRel/5a4n485h/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:216:25)
    at Promise (/Users/kudo/01_Work/Repos/expo/expo/android/versioned-react-native/ReactAndroid/hermes-engine/.cxx/MinSizeRel/5a4n485h/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:82:14)
    at anonymous (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:4657:25)
    at apply (native)
    at _pickDirectory (http://192.168.43.94:19000/node_modules/react-native-document-picker/src/index.bundle?platform=android&hot=false&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true:43:32)
    at apply (native)
    at pickDirectory (http://192.168.43.94:19000/node_modules/react-native-document-picker/src/index.bundle?platform=android&hot=false&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true:26:32)
    at ?anon_0_ (http://192.168.43.94:19000/App.bundle?platform=android&hot=false&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true:17:55)
    at next (native)
    at asyncGeneratorStep (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:4641:26)
    at _next (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:4660:29)
    at anonymous (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:4665:14)
    at tryCallTwo (/Users/kudo/01_Work/Repos/expo/expo/android/versioned-react-native/ReactAndroid/hermes-engine/.cxx/MinSizeRel/5a4n485h/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:61:9)
    at doResolve (/Users/kudo/01_Work/Repos/expo/expo/android/versioned-react-native/ReactAndroid/hermes-engine/.cxx/MinSizeRel/5a4n485h/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:216:25)
    at Promise (/Users/kudo/01_Work/Repos/expo/expo/android/versioned-react-native/ReactAndroid/hermes-engine/.cxx/MinSizeRel/5a4n485h/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:82:14)
    at anonymous (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:4657:25)
    at apply (native)
    at f (http://192.168.43.94:19000/App.bundle?platform=android&hot=false&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true:20:26)
    at App (http://192.168.43.94:19000/App.bundle?platform=android&hot=false&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true:24:17)
    at renderWithHooks (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:68096:33)
    at updateFunctionComponent (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:70373:41)
    at beginWork (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:71550:45)
    at beginWork$1 (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:74892:29)
    at performUnitOfWork (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:74405:29)
    at workLoopSync (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:74353:28)
    at renderRootSync (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:74335:25)
    at performSyncWorkOnRoot (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:74125:40)
    at flushSyncCallbacks (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:65500:36)
    at flushSync (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:74184:31)
    at scheduleRefresh (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:75150:20)
    at anonymous (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:47310:38)
    at forEach (native)
    at performReactRefresh (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:47304:31)
    at performReactRefresh (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:47135:48)
    at anonymous (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:428:40)
    at apply (native)
    at anonymous (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:29631:26)
    at _callTimer (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:29570:17)
    at callTimers (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:29726:19)
    at apply (native)
    at __callFunction (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:2826:36)
    at anonymous (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:2587:31)
    at __guard (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:2777:15)
    at callFunctionReturnFlushedQueue (http://192.168.43.94:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false:2586:21)

package.json

{
  "name": "app2",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "expo": "~48.0.15",
    "expo-status-bar": "~1.4.4",
    "react": "18.2.0",
    "react-native": "0.71.7",
    "react-native-document-picker": "^8.2.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0"
  },
  "private": true
}

npx expo --version 0.7.1

@MacKenzieHnC can you reproduce the issue with the above repo ?

Hello and thanks for reporting,
the behavior you're describing is expected. Please read the docs here: https://github.com/rnmods/react-native-document-picker#expo

Thank you 🙂

I see thanks, this only made sense after reading from the start https://docs.expo.dev/develop/development-builds/introduction/ (the url linked in this repo https://docs.expo.dev/develop/development-builds/create-a-build/?redirected kind of needs someone that already familiar with the ecosystem)