React Native/React Native_error

[React Native - ios/android] rn-fetch-blob 사용 시,WARN Require cycle

bocoder
728x90
반응형

* rn-fetch-blob 설치 후 사용 시, 아래와 같은 warning 발생

 WARN  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

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
 WARN  Require cycle: node_modules/rn-fetch-blob/index.js -> node_modules/rn-fetch-blob/polyfill/index.js -> node_modules/rn-fetch-blob/polyfill/XMLHttpRequest.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.
 WARN  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.

 

 

 

# 해결

 - 라이브러리의 4개 파일을 수정하면 된다.

 - 위치 : node_modules > rn-fetch-blob > polyfill > Blob.js, Fetch.js, FileReader.js, XMLHttpRequest.js

// before
import RNFetchBlob from '../index.js'
...

// after
import {NativeModules} from 'react-native';
const RNFetchBlob = NativeModules.RNFetchBlob
...

 

# 참고 

 - https://github.com/joltup/rn-fetch-blob/issues/183#issuecomment-450826541

728x90
반응형