首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在React Native iOS模拟器中隐藏警告?

如何在React Native iOS模拟器中隐藏警告?
EN

Stack Overflow用户
提问于 2016-02-10 15:39:16
回答 10查看 128.9K关注 0票数 160

我刚刚升级了我的React Native,现在iOS模拟器有一堆警告。除了修复它们,我如何隐藏这些警告,以便我可以看到下面是什么?

EN

回答 10

Stack Overflow用户

发布于 2016-05-10 19:52:55

根据React Native Documentation,可以通过将disableYellowBox设置为true来隐藏警告消息,如下所示:

代码语言:javascript
运行
复制
console.disableYellowBox = true;

更新: React原生0.63+

console.disableYellowBox已删除,现在您可以使用:

代码语言:javascript
运行
复制
import { LogBox } from 'react-native';
LogBox.ignoreLogs(['Warning: ...']); // Ignore log notification by message
LogBox.ignoreAllLogs();//Ignore all log notifications

忽略所有日志通知

票数 306
EN

Stack Overflow用户

发布于 2018-11-03 11:15:24

禁用黄色方框位置

代码语言:javascript
运行
复制
console.disableYellowBox = true; 

应用程序中的任何位置。通常在根文件中,因此它将同时适用于iOS和Android。

例如

代码语言:javascript
运行
复制
export default class App extends React.Component {
     render() {
          console.disableYellowBox = true;
          return (<View></View>);
     }
}
票数 25
EN

Stack Overflow用户

发布于 2019-09-27 17:28:21

在componentDidmount()中任何组件的生命周期method.like下的app.js文件中,您必须同时添加这两个参数,除非它们将不起作用。

代码语言:javascript
运行
复制
console.ignoredYellowBox = ['Warning: Each', 'Warning: Failed'];
console.disableYellowBox = true;
票数 14
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35309385

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档