Dennis Liu
Dennis Liu

Reputation: 2338

Expo Bare Workflow - How To Use And Setup react-native-pdf and react-native-blob-util - React Native

What is the proper way to use native module in react native expo bare workflow ? I want to use react-native-pdf and react-native-blob-util

But I got error :

TypeError: null is not an object (evaluating 'ReactNativeBlobUtil.DocumentDir')

And

Invariant Violation: "main" has not been registered. This can happen if:

I have following this link : https://openbase.com/js/react-native-pdf

I read in the expo documentation we can use native module using expo bare workflow. And now my project is bare workflow. In the middle of building my apps using expo bare workflow I got and error when using react-native-pdf and react-native-blob-util

I want when user click the button the apps will open the pdf file which have source link pdf from my server.

Is it possible to setup using this native module in expo bare workflow since bare workflow in the documentation said it like this :

https://docs.expo.dev/introduction/managed-vs-bare/

Bare Workflow

In the bare workflow the developer has complete control, along with the complexity that comes with that. You can use all packages from the Expo SDK, development builds, and all Expo and EAS Services. Configuration with app.json / app.config.js is mostly not supported in this context; instead, you will need to configure each native project directly.

Please give me a solution of this problem ? If it is not possible please point me to use another best pdf viewer.

Upvotes: 0

Views: 1764

Answers (2)

Erik Kodnar
Erik Kodnar

Reputation: 11

I had this same issue. The fix for me was to rebuild the development client first.

npx expo start --dev-client -c

Then run android/iOS.

There is no need to build with expo run:android.

Upvotes: 1

Dennis Liu
Dennis Liu

Reputation: 2338

Finally solved the problem.

Native Module cannot run in Expo Go

So expo publish will not working because it is run in Expo Go.

Instead, we must change to run in native. Use case example : npm run android or expo run:android. It will run into bare workflow with native module in our code.

Upvotes: 1

Related Questions