reactjs - 将对象传递给 console.warn 导致 react-native 错误
问题描述
当我传递对象console.warn
喜欢
console.warn({"1": "cool"})
它抛出以下错误
argument[0].indexOf is not a function
但是在传递字符串时它工作得很好
console.warn("some text")
如前所述,它应该同时接受字符串和对象。
字符串或对象
解决方案
console.warn
React Native 中的消息显示在带有YellowBox的本机应用程序中。YellowBox 只能显示字符串,不能显示对象。
如果您只想在使用远程调试器调试应用程序时看到警告,您可以使用console.disableYellowBox = true;
. 然后,您也可以使用console.warn
对象,但是您不会在应用程序中看到任何警告。