- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我有一个一般性问题和两个更具体的问题。
所有这些React-Native documentation关于忽略特定警告的说法是:
"YellowBoxes can be disabled during development by using console.disableYellowBox = true;. Specific warnings can be ignored programmatically by setting an array of prefixes that should be ignored: console.ignoredYellowBox = ['Warning: ...'];."
所以React-Native提供了这段代码,但是我不知道如何指定警告的名称:
console.ignoredYellowBox = ['Warning: ReactNative.createElement'];
最佳答案
虽然文档中没有详细介绍,但请查看 the YellowBox component code ,我们可以看到它使用了一个简单的字符串匹配来过滤警告:
return (
Array.isArray(console.ignoredYellowBox) &&
console.ignoredYellowBox.some(
ignorePrefix => warning.startsWith(String(ignorePrefix))
)
);
鉴于此,您只需执行以下操作即可禁用问题中列出的错误的覆盖:
console.ignoredYellowBox = [
'NetInfo\'s "change" event', // Safe to ignore because reasons
'Using <Image> with children' // TODO: Will be fixed in release foo
];
您可以根据需要使匹配更具体或更模糊,因为它是一个简单的字符串匹配。
请注意,错误仍将记录到控制台,上面的配置只是禁用了给定错误的大黄色覆盖。
在 React Native 的 future 版本中,console.ignoredYellowBox
将被弃用并由 YellowBox.ignoreWarnings
取代,后者将以相同的方式工作。
关于javascript - console.ignoredYellowBox 我怎么知道要使用什么前缀?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46199789/
我有一个一般性问题和两个更具体的问题。 我如何根据黄框警告消息判断如何在 React-Native 中忽略它? 如何忽略此特定警告? 3. 如何忽略此特定警告? 所有这些React-Native do
我是一名优秀的程序员,十分优秀!