Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: RNFetchBlob.fs.stat is not a function #537

Open
syedibrahimt opened this issue Jan 21, 2021 · 12 comments
Open

TypeError: RNFetchBlob.fs.stat is not a function #537

syedibrahimt opened this issue Jan 21, 2021 · 12 comments

Comments

@syedibrahimt
Copy link
Contributor

What react-native version are you using?
0.63.4

What react-native-pdf version are you using?
https://github.com/wonday/react-native-pdf

Platform
windows

Steps to reproduce:
Install the windows version using the following steps(https://github.com/wonday/react-native-pdf#windows-installation)

image

Show us the code you are using?

<Pdf style={{flex: 1, width: 200, height: 500}} source={source} />

@stmoy
Copy link

stmoy commented Jan 21, 2021

CC: @jaimecbernardo - does the other PR solve this issue? #535

@jaimecbernardo
Copy link
Contributor

Hi @syedibrahimt .
Until rn-fetch-blob is usable on Windows, the import of rn-fetch-blob is not called on Windows, since it'd crash.
If you're using a version of rn-fetch-blob which runs on Windows, you'd have to replace these lines:

let RNFetchBlob = {
fs : {
dirs: {
CacheDir: ''
}
}
};
if (Platform.OS !== 'windows') {
RNFetchBlob = require('rn-fetch-blob');
}

with

import RNFetchBlob from 'rn-fetch-blob';

Once there's a rn-fetch-blob version that supports Windows out there, a PR will be opened here with this change as well.

Please let me know if this change fixes the issue for you.

@stmoy , it doesn't. That PR fixes the require on iOS and Android.

@stmoy
Copy link

stmoy commented Jan 21, 2021

Until rn-fetch-blob is usable on Windows, the import of rn-fetch-blob is not called on Windows, since it'd crash

rn-fetch-blob has a Windows implementation that is currently living in PR limbo (since the module is unmaintained): joltup/rn-fetch-blob#701

If @syedibrahimt has the rn-fetch-blob dependency included in the app (directly from PR), could the PDF module use it?

@jaimecbernardo
Copy link
Contributor

If @syedibrahimt has the rn-fetch-blob dependency included in the app (directly from PR), could the PDF module use it?

Yes, as long as the previous lines lines were changed. I'll open a Draft PR so that this is easier to consume.

@jaimecbernardo
Copy link
Contributor

I've opened a Draft PR in order to use rn-fetch-blob on Windows as well: #538
It's meant to be used alongside joltup/rn-fetch-blob#701

In order to use the Draft PR, run the following inside the react-native project:

yarn add wonday/react-native-pdf#538/head

@RonRadtke
Copy link

I forked it and will try to keep it up to date. But will take a bit to fix everything and integrate some old PRs. If anyone wants to help, feel free to contact me :) I will also integrate the windows implementation
You can find it here: https://github.com/RonRadtke/react-native-blob-util

@syedibrahimt
Copy link
Contributor Author

I've opened a Draft PR in order to use rn-fetch-blob on Windows as well: #538
It's meant to be used alongside joltup/rn-fetch-blob#701

In order to use the Draft PR, run the following inside the react-native project:

yarn add wonday/react-native-pdf#538/head

Thanks @jaimecbernardo . I will take this draft PR and try.

@syedibrahimt
Copy link
Contributor Author

I've opened a Draft PR in order to use rn-fetch-blob on Windows as well: #538
It's meant to be used alongside joltup/rn-fetch-blob#701
In order to use the Draft PR, run the following inside the react-native project:

yarn add wonday/react-native-pdf#538/head

Thanks @jaimecbernardo . I will take this draft PR and try.

@jaimecbernardo . I tried this one. But still not working. The app crashes without any logs.

@jaimecbernardo
Copy link
Contributor

Hi @syedibrahimt ,
There are currently some issues with the Windows rn-fetch-blob implementation, where the file is not being saved to disk and it's not behaving as expected when compared to other platforms. There's currently a conversation going on about this: joltup/rn-fetch-blob#701 (comment)

Since you've, tried there's a new commit in that PR that saves the file to disk as expected by react-native-pdf, but still fails some time: joltup/rn-fetch-blob@518d48b

I've been able to load pdfs after those changes, so you might want to give it another try, but I still spot some flakiness in the behavior which is still leading to some crashes: joltup/rn-fetch-blob#701 (comment)

I'll keep looking for other sources for the flakiness as well.

@bicanezin
Copy link

Any solutions? I tried everything :(

@jaimecbernardo
Copy link
Contributor

@bicanezin ,
What steps did you follow?
Did you take the Windows-specific installation instructions from the README.md into account?
https://github.com/wonday/react-native-pdf/tree/ab11418713a5a5722b65688b2c7f4d2c01a0bae1#installation

@bicanezin
Copy link

bicanezin commented Mar 2, 2021

I finally solved my problem!!!!
What helped me:
#174 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants