Skip to content

Instantly share code, notes, and snippets.

@jeserodz
Last active September 26, 2019 17:02
Show Gist options
  • Save jeserodz/2ffca449e0bbe2c03dadbd4e5e14c491 to your computer and use it in GitHub Desktop.
Save jeserodz/2ffca449e0bbe2c03dadbd4e5e14c491 to your computer and use it in GitHub Desktop.
Enable Network Debugging in React Native
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);
/*
* 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