wonday / react-native-pdf

A <Pdf /> component for react-native
MIT License
1.6k stars 553 forks source link

"TypeError: Cannot read property 'getConstants' of null, js engine: hermes " after installing "react-native-pdf" package in expo #834

Open Rahmathirshad opened 6 months ago

Rahmathirshad commented 6 months ago

react-native version - "0.74.1", react-native-pdf version - "^6.7.5" "react-native-blob-util" version - "^0.19.8",

I'm using EXPO and I'm trying to use 'react-native-pdf' package to open pdf but I'm getting this error "TypeError: Cannot read property 'getConstants' of null, js engine: hermes" just after launching the app in both expo go and also in development build.

I have carefully followed all the steps to add configs and building app but still I'm getting this error, please help.

karam1ashqar commented 5 months ago

is this on ios? if yes what sdk version

anirudhk-tech commented 5 months ago

Facing the same issue here. I'm developing on Android.

srt54558 commented 5 months ago

I second this. I cannot get around this issue. Just importing the module gets me this error.

tested on android 15 preview

victorgoecking commented 5 months ago

Same problem here, any solution?

anirudhk-tech commented 5 months ago

Same problem here, any solution?

For everyone who's experiencing this problem, what worked for me is building the app all over again. The second time through when you run eas build, make sure you installed react-native-pdf before you start your build. So npx create-expo-app, npm i react-native-pdf, and then eas build in that order.

I think it's because expo automatically creates internal components that go with native module if it's installed before build. If it's installed after, you'd have to manually create these internal components, which I don't know how to. I'm not sure whether this is the reason or not, but it's what I heard.

Samide47 commented 3 months ago

Same problem here, any solution?

For everyone who's experiencing this problem, what worked for me is building the app all over again. The second time through when you run eas build, make sure you installed react-native-pdf before you start your build. So npx create-expo-app, npm i react-native-pdf, and then eas build in that order.

I think it's because expo automatically creates internal components that go with native module if it's installed before build. If it's installed after, you'd have to manually create these internal components, which I don't know how to. I'm not sure whether this is the reason or not, but it's what I heard.

works like a charm 👍