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.
There are different way to check if the application is build using debug or release certificate, but the following way seems best to me. According to the info in Android documentation Signing Your Application, debug key contain following subject distinguished name: "CN=Android Debug,O=Android,C=US".
You can also use the ⌘D keyboard shortcut when your app is running in the iOS Simulator, or ⌘M when running in an Android emulator on Mac OS and Ctrl+M on Windows and Linux. Alternatively for Android, you can run the command adb shell input keyevent 82 to open the dev menu (82 being the Menu key code).
if (__DEV__) { console.log('I am in debug'); }
You can see this approach is being used in React Native repository.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With