React Native 禁用应用程序屏幕底部的 console.warn 黄色框
React Native disable console.warn yellow box from the app screen bottom
我想用一行代码删除 console.warn
和碰巧出现在我的 React 本机应用程序上的所有其他警告消息。在我通过在我的 App.js
中添加以下内容来实现这一点之前
console.disableYellowBox = true;
但不知何故它现在不起作用,代码仍然存在于我的 App.js 但黄色框上的警告仍然显示在屏幕底部。由于我的应用程序很大,它使用了多个包,而且我还在很多地方添加了 console.warn
,我需要一个解决方案来从一个地方禁用它
有人请帮助我确定为什么 console.disableYellowBox = true;
不起作用,或者请提供一些替代解决方案来解决这个问题。
My react native version is 0.60.5
如有任何帮助,我们将不胜感激。
提前致谢
试试这个,它会删除明显的警告。
YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated', 'Module RCTImageLoader', 'RNDeviceInfo', 'Warning: An update']);
对于React-naitve 0.63
LogBox.ignoreAllLogs()
及更早版本
YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated', 'Module RCTImageLoader', 'RNDeviceInfo', 'Warning: An update']);
我想用一行代码删除 console.warn
和碰巧出现在我的 React 本机应用程序上的所有其他警告消息。在我通过在我的 App.js
console.disableYellowBox = true;
但不知何故它现在不起作用,代码仍然存在于我的 App.js 但黄色框上的警告仍然显示在屏幕底部。由于我的应用程序很大,它使用了多个包,而且我还在很多地方添加了 console.warn
,我需要一个解决方案来从一个地方禁用它
有人请帮助我确定为什么 console.disableYellowBox = true;
不起作用,或者请提供一些替代解决方案来解决这个问题。
My react native version is 0.60.5
如有任何帮助,我们将不胜感激。
提前致谢
试试这个,它会删除明显的警告。
YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated', 'Module RCTImageLoader', 'RNDeviceInfo', 'Warning: An update']);
对于React-naitve 0.63
LogBox.ignoreAllLogs()
及更早版本
YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated', 'Module RCTImageLoader', 'RNDeviceInfo', 'Warning: An update']);