-
Notifications
You must be signed in to change notification settings - Fork 787
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
Require cycle #183
Require cycle #183
Comments
I'm also getting these warnings on the new version of react-native.
|
Same issue |
same issue |
1 similar comment
same issue |
Yes, I've faced the same issue here. |
Require cycle: node_modules/rn-fetch-blob/index.js -> node_modules/rn-fetch-blob/polyfill/index.js -> node_modules/rn-fetch-blob/polyfill/Blob.js -> node_modules/rn-fetch-blob/index.js |
Same issue :( |
same here |
same here, any idea? |
I've got the same. |
Same Here |
Any one already working on this issue? Or any one has an idea to solve this? |
@AsadSaleh This is not a critical problem, just a warning for 'maybe there is something wrong in your code', so you can simply ignore this warning by add codes like bellow, and wait someone will fix this warning ...
|
any update on this ? |
@wd This is a warning but needs to be dealt with. This has come up with new react-native version (0.57) and requires certain code restructuring in rn-fetch-blob library. Is anyone working on this? |
I also encountered this problem today. |
Modify these files can avoid require cycle: // import RNFetchBlob from '../index.js' |
this problem has resolved, thanks brother |
there is going to be a PR for @zhuxianqin fix ??? |
@zhuxianqin can you please submit a PR with this fix? |
sorry, I don't know how to release github project, I will try to do it in several days |
to develop this project, I need to follow instructions below: |
@zhuxianqin seems that they are not adding it, it sucks man :( Seems that you know this library a lot, though. Can you help me with something? I created this post |
This should be fixed. I'm glad react-native now warns about this but there should have never been cyclic dependencies in the first place. here it is solved with constructor injection: software-mansion/react-native-svg#773 Another way to solve this is to make an interface with a setter and a getter and require the interface instead of the original class. The original file uses the setter and all others use the getter. interface.js: let thing = {}
export function getThing () {
return thing
}
export function setThing (thingToSet) {
thing = thingToSet
} thing.js: import {setThing} from './interface'
class Thing {}
setThing(Thing) other files: import {getThing} from './interface'
const Thing = getThing() |
@ThaJay yea man, i receive like 6-7 warning notifications every time i refresh the app, is getting super annoying. |
This did the trick on RN 0.57 |
@vitor-veras i have to put the fetch-blob file in my app and edit it then? no other way until they fix this? :/ i don't get it, i assume i don't have to update these files directly from node_modules otherwise it will be over-written whenever i do another npm install... so how should i do it? |
That's only a warning from React Native, but it can slowdown the app performance. And yes if you update the package with npm/yarn the fix will go away. There's no proper aproach to this i think, hopefully the dev team fix this soon. There is actually a PR for this #296 . |
As mentioned by @alpha0010 in #296 one would encounter problems where RNFetchBlob is called within the files the import is removed from. @ThaJay would you be able to submit a PR? |
Removed all the requiring cycles by changing all to use directly the NativeModules
This also works in react-native-fetch-blob Thanks Dude! |
Thanks, this works fine |
Thanks brother, @zhuxianqin !Note: I made a patch from @zhuxianqin's solution. I hope that makes it easier 😃
|
@storkyle , thanks for the patch. this works for me. Question: does anybody know of a maintained fork or a good replacement for rn-fetch-blob? |
Self promotion: I wrote https://github.com/alpha0010/react-native-file-access when this library was marked as unmaintained. API is similar, but implementation is completely new. Feature set reduced to what I thought were the essentials (less code/simpler code means fewer places for bugs... in theory). |
Awesome. This fixed the issue for me |
I resolved this scriptPlease write in var fs = require('fs');
const replaced = `import RNFetchBlob from '../index.js'`;
const replacement = `import {NativeModules} from 'react-native';\nconst RNFetchBlob = NativeModules.RNFetchBlob`;
const files = [
'node_modules/rn-fetch-blob/polyfill/Fetch.js',
'node_modules/rn-fetch-blob/polyfill/Blob.js',
'node_modules/rn-fetch-blob/polyfill/XMLHttpRequest.js',
];
files.forEach(file => {
fs.readFile(file, 'utf8', function (err, data) {
if (err) {
return console.log(err);
}
var result = data.replace(new RegExp(replaced, 'g'), replacement);
fs.writeFile(file, result, 'utf8', function (err) {
if (err) return console.log(err);
});
});
}); and in "scripts": {
.....
"postinstall": "node scripts/rn-fetch-blob_warning.js"
}, Please reinstall. ( |
Thank you @storkyle ... Don't need to manually patch each time packages are installed with this solution. |
rn-fetch-blob is no longer maintained and a [require cycle issue](joltup/rn-fetch-blob#183) constantly shows warnings in the latest version of RN when we start the app. This updates the package to use [react-native-blob-util](https://github.com/RonRadtke/react-native-blob-util) instead which is a maintained fork of the original package.
rn-fetch-blob is no longer maintained and a [require cycle issue](joltup/rn-fetch-blob#183) constantly shows warnings in the latest version of RN when we start the app. This updates the package to use [react-native-blob-util](https://github.com/RonRadtke/react-native-blob-util) instead which is a maintained fork of the original package.
Worked for me |
Same issue |
Thanks man this issue has been resolved |
this is all are fixing not a permanent solution. |
It works for me. thanks |
Cyclic dependencies for almost 4 years and still not fixed? That's... Unfortunate |
Try this forked package, still actively maintained. |
Hello, this still exists on: "react": "18.0.0", Update: Fix after I installed |
it works for me, many thanks |
* master: Add timeout for ressource Fix issue : joltup#183 (comment) some fixes fix downloaded pdf # Conflicts: # android/src/main/java/com/ReactNativeBlobUtil/Utils/PathResolver.java # polyfill/Blob.js # polyfill/Fetch.js # polyfill/XMLHttpRequest.js
Require cycle: node_modules/rn-fetch-blob/index.js -> node_modules/rn-fetch-blob/polyfill/index.js -> node_modules/rn-fetch-blob/polyfill/Fetch.js -> node_modules/rn-fetch-blob/index.js Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle. |
Require cycle: node_modules/rn-fetch-blob/index.js -> node_modules/rn-fetch-blob/polyfill/index.js -> node_modules/rn-fetch-blob/polyfill/FileReader.js -> node_modules/rn-fetch-blob/index.js
It is recommended to solve this problem!
The text was updated successfully, but these errors were encountered: