How can I determine if my React Native app is a debug or release build from JavaScript code?

JavascriptIosReact Native

Javascript Problem Overview


I'd like to add some debug-only UI to my React Native app, but I can't find any equivalent of RCT_DEBUG or RCT_DEV compile-time flags in the JavaScript environment. Is there one?

Use case: I want to add a status bar that shows the number of HTTP requests initiated by my app. Obviously this is not part of a shipping app, but it would help me check my work while in development and testing.

Javascript Solutions


Solution 1 - Javascript

if (__DEV__) {
    console.log('I am in debug');
}

You can see this approach is being used in React Native repository.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionescoutenView Question on Stackoverflow
Solution 1 - Javascriptrmevans9View Answer on Stackoverflow