如何抑制由于本机反应中的第三方 PropTypes 库引起的警告 [英] How to suppress warning due to a third-party PropTypes library in react native

查看:35
本文介绍了如何抑制由于本机反应中的第三方 PropTypes 库引起的警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 React Native 中使用样式表时收到很多警告,如下图.

I got a plenty of warnings while using Stylesheet in React Native as following image.

iOS 模拟器警告

如何压制?

推荐答案

无法禁用特定组件的警告,但您可以禁用应用程序中不同类型的警告.要禁用所有警告,请使用:

There is no way to disable warnings for a specific component, but you can disable different types of warnings in your app. To disable all warnings, use:

console.disableYellowBox = true;

要仅禁用以给定字符串开头的某些警告,请指定要过滤掉的前缀数组:

To disable only certain warnings that start with a given string, specify an array of prefixes to filter out:

console.ignoredYellowBox = ['Warning: ...'];

例如,对于问题中的警告,您可以编写:

For example, for the warning in the question you could write:

console.ignoredYellowBox = [
  'Warning: You are manually calling a React.PropTypes validation',
];

这篇关于如何抑制由于本机反应中的第三方 PropTypes 库引起的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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