如何确定我的React Native应用程序是否是JavaScript代码的调试或发布版本? [英] How can I determine if my React Native app is a debug or release build from JavaScript code?

查看:139
本文介绍了如何确定我的React Native应用程序是否是JavaScript代码的调试或发布版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

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

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.

推荐答案

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

你可以请参阅此方法正在 React Native repository

这篇关于如何确定我的React Native应用程序是否是JavaScript代码的调试或发布版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆