Last active
September 26, 2019 17:02
-
-
Save jeserodz/2ffca449e0bbe2c03dadbd4e5e14c491 to your computer and use it in GitHub Desktop.
Enable Network Debugging in React Native
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {AppRegistry} from 'react-native'; | |
import App from './App'; | |
import {name as appName} from './app.json'; | |
import './src/utils/RNNetworkDebugging'; // <-- INCLUDE HERE | |
AppRegistry.registerComponent(appName, () => App); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Allows to Inspect network requests that use XMLHttpRequest | |
* or fetch on the Network tab of Chrome Developer Tools. | |
*/ | |
global.XMLHttpRequest = global.originalXMLHttpRequest | |
? global.originalXMLHttpRequest | |
: global.XMLHttpRequest; | |
global.FormData = global.originalFormData | |
? global.originalFormData | |
: global.FormData; | |
fetch; // Ensure to get the lazy property | |
if (window.__FETCH_SUPPORT__) { | |
// it's RNDebugger only to have | |
window.__FETCH_SUPPORT__.blob = false; | |
} else { | |
/* | |
* Set __FETCH_SUPPORT__ to false is just work for `fetch`. | |
* If you're using another way you can just use the native Blob and remove the `else` statement | |
*/ | |
global.Blob = global.originalBlob ? global.originalBlob : global.Blob; | |
global.FileReader = global.originalFileReader | |
? global.originalFileReader | |
: global.FileReader; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment