使用 react-native-svg 执行 UI 块时抛出异常
Exception thrown while executing UI block when using react-native-svg
我的应用程序突然开始崩溃并给出错误:
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;
根据 Javlon 的评论,解决方案是使用 npm uninstall react-native-svg
或 yarn remove react-native-svg
删除软件包,然后使用 expo install react-native-svg
再次安装它
我的应用程序突然开始崩溃并给出错误:
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;
根据 Javlon 的评论,解决方案是使用 npm uninstall react-native-svg
或 yarn remove react-native-svg
删除软件包,然后使用 expo install react-native-svg