React native 使用本机svg时执行UI块时引发异常
我的应用程序突然开始崩溃,并给了我这个错误:React native 使用本机svg时执行UI块时引发异常,react-native,expo,react-native-svg,React Native,Expo,React Native Svg,我的应用程序突然开始崩溃,并给了我这个错误: Exception thrown while executing UI block: -[__NSCFNumber firstObject]: unrecognized selector sent to instance 0xb553069cd18775de` 过了一段时间,我能够分离出产生错误的部分,并发现它与从react native Svg导入的Svg组件有关 我试着删除并重新安装node_模块,试着重置缓存,甚至试着从头开始创建一个新的e
Exception thrown while executing UI block: -[__NSCFNumber firstObject]: unrecognized selector
sent to instance 0xb553069cd18775de`
过了一段时间,我能够分离出产生错误的部分,并发现它与从react native Svg导入的Svg组件有关我试着删除并重新安装node_模块,试着重置缓存,甚至试着从头开始创建一个新的expo应用程序,它只渲染Svg组件,但问题仍然存在 在android上,我收到一条不同的错误消息:
Error while updating property 'fill' of a View managed by: RNSVGGroup
null
java.Lang.Double cannot be cast to
java.Lang.String
我的代码是这样的:
从“React”导入React;
从“react native”导入{View,StyleSheet};
从“react native Svg”导入{Svg};
常量应用=()=>(
);
const styles=StyleSheet.create({
容器:{
弹性:1,
为内容辩护:“中心”,
对齐项目:“居中”,
}
});
导出默认应用程序;
根据Javlon的评论,解决方案是使用
npm卸载react-native svg
或Warn移除react-native svg
删除包,然后使用
expo安装react-native svg
再次安装包,情况相同。重新安装带有“expo install”的react native svg包对我很有帮助。这确实解决了我的问题。。谢谢@javlontulkinovi如果您是使用npm安装的,请先使用npm uninstall
删除该软件包。然后使用@JavlonTulkinov提到的expo安装
。如果任何人在react native svg图表
和expo中遇到此问题,请确保卸载react native svg图表
和react native svg
,然后首先执行expo安装react native svg
,然后npm安装--保存本地svg图表
。我为此浪费了一整天的时间。