Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 如何在react native中从控制台日志中删除警告_React Native - Fatal编程技术网

React native 如何在react native中从控制台日志中删除警告

React native 如何在react native中从控制台日志中删除警告,react-native,React Native,我正在用react native编写一个应用程序,我有一个恼人的“设置长时间警告的时间” 我已使用此代码删除手机上的黄色方框警告 import {YellowBox} from 'react-native'; YellowBox.ignoreWarnings(['Setting a timer']); 但是我仍然不知道如何从控制台日志中删除该警告,正如您在这里看到的 你知道如何在控制台日志中禁用警告吗?(当然没有禁用日志记录本身,因为我希望能够调试..) 编辑:不确定这是否重要,我正在使用

我正在用react native编写一个应用程序,我有一个恼人的“设置长时间警告的时间”

我已使用此代码删除手机上的黄色方框警告

import {YellowBox} from 'react-native';
YellowBox.ignoreWarnings(['Setting a timer']); 
但是我仍然不知道如何从控制台日志中删除该警告,正如您在这里看到的

你知道如何在控制台日志中禁用警告吗?(当然没有禁用日志记录本身,因为我希望能够调试..)

编辑:不确定这是否重要,我正在使用Expo运行我的应用程序


非常感谢:)

您可以使用

安装

npm install babel-plugin-transform-remove-console --save-dev
通过babelrc(推荐)

babel.config.js

module.exports=函数(api){
api.cache(true);
常量预设=[…];
const插件=[[“转换移除控制台”,{“排除”:[“错误”,“警告”]}]];
返回{
预设,
插件
};
}

您可以使用

安装

npm install babel-plugin-transform-remove-console --save-dev
通过babelrc(推荐)

babel.config.js

module.exports=函数(api){
api.cache(true);
常量预设=[…];
const插件=[[“转换移除控制台”,{“排除”:[“错误”,“警告”]}]];
返回{
预设,
插件
};
}

因为我使用的是Expo,所以我没有.babelrc文件,我有一个名为babel.config.js的文件。我试图按照以下方式编写它:module.exports=function(api){api.cache(true);return{presets:['babel-preset-expo'],env:{development:{plugins:[[“transform remove console”,{“exclude”:[“warn”]}};}但是我仍然在我的控制台上看到了警告..我还试图像这样编写babel.config.js文件module.exports=function(api){api.cache(true);const presets=['babel-preset-expo'];const plugins=[[“transform remove console”,{“exclude”:[“warn”]}]]];return{presets,plugins};};但是警告仍然出现在我的控制台中。尝试了一下,仍然看到警告:(我现在做的是转到node_modules/react native/Libraries/Core/Timers/JSTimers.js并删除if(DEV&&is_ANDROID&&duration>MAX_TIMER_duration_MS)。可能不是最好的解决方案,但至少我可以更轻松地调试。。因为我使用的是Expo,所以我没有.babelrc文件,我有一个名为babel.config.js的文件。我尝试按以下方式编写:module.exports=function(api){api.cache(true);return{presets:['babel-preset-Expo',env:{development:{plugins:[[“transform remove console”,{“exclude”:[“warn”]}]}};}但是我仍然在我的控制台上看到警告..我还尝试编写babel.config.js文件,比如module.exports=function(api){api.cache(true);const presets=['babel-preset-expo'];const plugins=[[“transform remove console”,{“排除”:[“warn”]}];返回{pretests,plugins};};但是警告仍然出现在我的控制台中。尝试了一下,仍然看到警告:(我现在做的是转到node_modules/react native/Libraries/Core/Timers/JSTimers.js并删除if(DEV&&is_ANDROID&&duration>MAX_TIMER_duration_MS).可能不是最好的解决方案,但至少我可以更轻松地调试。。