admin管理员组文章数量:1244219
I have one general questions and two more specific ones.
- How can I tell from a yellowbox warning message how to ignore it in React-Native?
- How do I ignore this specific warning?
3. And how do I ignore this specific warning?
All that React-Native documentation says about ignoring specific warnings is:
"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: ...'];."
So React-Native offers this piece of code, but I don't know how to specify the name of the warning:
console.ignoredYellowBox = ['Warning: ReactNative.createElement'];
I have one general questions and two more specific ones.
- How can I tell from a yellowbox warning message how to ignore it in React-Native?
- How do I ignore this specific warning?
3. And how do I ignore this specific warning?
All that React-Native documentation says about ignoring specific warnings is:
"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: ...'];."
So React-Native offers this piece of code, but I don't know how to specify the name of the warning:
console.ignoredYellowBox = ['Warning: ReactNative.createElement'];
Share
Improve this question
asked Sep 13, 2017 at 14:09
WaltariWaltari
1,2493 gold badges36 silver badges67 bronze badges
2 Answers
Reset to default 12While it isn't covered in detail in the docs, looking at the YellowBox ponent code, we can see that it uses a simple string match to filter the warnings:
return (
Array.isArray(console.ignoredYellowBox) &&
console.ignoredYellowBox.some(
ignorePrefix => warning.startsWith(String(ignorePrefix))
)
);
Given this, you can disable the overlays for the errors outlined in the questions simply by doing the following:
console.ignoredYellowBox = [
'NetInfo\'s "change" event', // Safe to ignore because reasons
'Using <Image> with children' // TODO: Will be fixed in release foo
];
You can make the matches more specific or more ambiguous as needed, since it's a simple string match.
Note that the errors will still be logged to the console, the above configuration simply disables the large yellow overlay for the given errors.
In future releases of React Native console.ignoredYellowBox
will be deprecated and superseded by YellowBox.ignoreWarnings
which will work in an identical fashion.
"To disable the yellow box place console.disableYellowBox = true; anywhere in your application. Typically in the root file so it will apply to both iOS and Android."
If you want more control over these messages, check out this link for more in-depth infos: Disable the Yellow Box in React Native
本文标签: javascriptconsoleignoredYellowBox how do I know what prefix to useStack Overflow
版权声明:本文标题:javascript - console.ignoredYellowBox how do I know what prefix to use? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740209263a2241689.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论