Skip to content

Instantly share code, notes, and snippets.

@dchowitz
Last active February 7, 2019 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dchowitz/745b93c408c071dcad0f486594b11fbe to your computer and use it in GitHub Desktop.
Save dchowitz/745b93c408c071dcad0f486594b11fbe to your computer and use it in GitHub Desktop.
Enable/configure debug output in React Native

Lots of dependencies rely on the debug module for debug output. When debugging a React Native app with Chrome Developer tools, you can enable the debug output with

window.localStorage.debug = 'namespace'

in the console.

However, sometimes you need the debug output without running your app in Chrome's V8 context due to some subtle differences between the Javascript execution engines.

In order to achieve this, you can simply add enableDebug.js to your project and import it in your index.js like this:

import enableDebug from "./enableDebug";
enableDebug("*"); // this enables all debug output, look in the debug documentation for configuration options

After that you will see your debug output and that of your dependencies by running

react-native log-android
# resp.
react-native log-ios

in a terminal.

export default function(namespaces) {
if (!window.localStorage) {
window.localStorage = {
removeItem: function() {}
};
}
window.localStorage.debug = namespaces;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment