如何确定我的React Native应用程序是否是JavaScript代码的调试或发布版本?

时间:2020-12-31 21:06:03

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?

我想在我的React Native应用程序中添加一些仅调试的UI,但我在JavaScript环境中找不到任何等效的RCT_DEBUG或RCT_DEV编译时标志。有吗?

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.

使用案例:我想添加一个状态栏,显示我的应用程序发起的HTTP请求数。显然这不是一个发货应用程序的一部分,但它可以帮助我在开发和测试中检查我的工作。

1 个解决方案

#1


81  

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

#1


81  

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