我的应用突然开始崩溃并给了我这个错误:
Exception thrown while executing UI block: -[__NSCFNumber firstObject]: unrecognized selector
sent to instance 0xb553069cd18775de`
一段时间后,我能够隔离产生错误的部分,并发现它与从 react-native-svg 导入的 Svg 组件有关。
我尝试删除并重新安装 node_modules 并尝试重置缓存,甚至尝试从头开始创建一个新的 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
这是我的代码的样子:
import React from 'react';
import { View, StyleSheet } from 'react-native';
import { Svg } from 'react-native-svg';
const App = () => (
<View style={styles.container}>
<Svg width={100} height={100}>
</Svg>
</View>
);
const styles = StyleSheet.create({
container:{
flex: 1,
justifyContent: 'center',
alignItems: 'center',
}
});
export default App;