Open albert17 opened 1 year ago
Same issue.
I'm using react-native:0.66.5
@albert17 Did you find a solution for this issue?
Any solution
import Pdf from 'react-native-pdf'; TypeError: Cannot read properties of null (reading 'getConstants')
@testing-library/react-native
Using with expo 48(react-native 0.71.4) same problem.
With
react-native-pdf@6.4.0
react-native-blob-util@0.13.18
I get ERROR: TypeError: Cannot read property 'DocumentDir' of null, js engine: hermes
With
react-native-pdf@6.6.2
react-native-blob-util@0.13.18
ERROR: TypeError: Cannot read property 'DocumentDir' of null, js engine: hermes
With
react-native-pdf@6.4.0
react-native-blob-util@0.17.3
ERROR TypeError: Cannot read property 'getConstants' of null, js engine: hermes
Maybe problem is in react-native-blob-util and not in react-native-pdf?
Searched and found this ticket: https://github.com/RonRadtke/react-native-blob-util/issues/204
Original idea why it should work with expo: https://github.com/expo/examples/tree/master/with-pdf
@kalinchuk Still facing same issue. I have tried mocking but no luck.
Any update on that? Facing the same issue.
Facing the same issue
Same
Some solution mentioned here, but have't tested.
https://github.com/RonRadtke/react-native-blob-util/issues/204#issuecomment-1579012034
@kullarkert
Some solution mentioned here, but have't tested.
That's specifically for unit tests, while I'm observing this when running the app on an android simulator for realtime development.
@mgithubmessier Did you add this line in android/app/build.gradle
?
packagingOptions {
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/x86_64/libjsc.so'
pickFirst 'lib/arm64-v8a/libjsc.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
}
@mgithubmessier Did you add this line in
android/app/build.gradle
?packagingOptions { pickFirst 'lib/x86/libc++_shared.so' pickFirst 'lib/x86_64/libjsc.so' pickFirst 'lib/arm64-v8a/libjsc.so' pickFirst 'lib/arm64-v8a/libc++_shared.so' pickFirst 'lib/x86_64/libc++_shared.so' pickFirst 'lib/armeabi-v7a/libc++_shared.so' }
try but not working
Facing the same
For anyone running into this outside of tests in expo development builds, I ran into this today because I hadn't added the expo config plugins. Once I installed them and rebuilt the development build it all worked fine.
react-native-blob-util
depends on react native turbo module, which should be implemented with native code(android/ios).
This error may occur even we use only react-native-blob-util
like this issue.
To resolve this, we may need to overwrite turbo module with jest mock.
Simplest way to suppress the error is mocking react-native-pdf
itself.
This example for jest setup code may work.
jest.mock('react-native-pdf', () => { return () => <></>})
react-native-blob-util
depends on react native turbo module, which should be implemented with native code(android/ios). This error may occur even we use onlyreact-native-blob-util
like this issue. To resolve this, we may need to overwrite turbo module with jest mock. Simplest way to suppress the error is mockingreact-native-pdf
itself. This example for jest setup code may work.jest.mock('react-native-pdf', () => { return () => <></>})
Thanks it works
What
react-native
version are you using? 0.69.3What
react-native-pdf
version are you using? 6.6.2What platform does your issue occur on? (android/ios/both) Both
Describe your issue as precisely as possible : 1) Steps to reproduce the issue or to explain in which case you get the issue Run a test that imports PDF. Application runs fine, only
npm run test
fails. 2) Interestinglogs
Show us the code you are using?