我试图使用Chart Kit库运行基本的React Native App,但出现此错误: CLICK FOR IMAGE: Exception thrown while executing UI block: __NSCFNumber firstObject: unrecognized selector sent to instance 0xa3576e305374b97e
有人知道如何解决吗?
这是我的代码:
import React from 'react';
import { View, StyleSheet } from 'react-native';
import { LineChart, Grid } from 'react-native-svg-charts';
class LineChartExample extends React.PureComponent {
render() {
const data = [50, 10, 40, 95, -4, -24, 85, 91, 35, 53, -53, 24, 50, -20, -80];
return (
<LineChart
style={{ height: 200 }}
data={data}
svg={{ stroke: 'rgb(134, 65, 244)' }}
contentInset={{ top: 20, bottom: 20 }}
>
<Grid />
</LineChart>
)
}
}
export default LineChartExample;
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
答案 0 :(得分:2)
解决了!我在项目中使用Expo,并在npm中安装react-native-chart-kit和react-native-svg。由于某些原因,使用nmp出现了错误,但是在卸载并使用“ expo install”安装再次安装react-native-chart-kit之后,一切正常。
答案 1 :(得分:1)
我有同样的问题,但是使用“ expo install install react-native-chart-kit”没有解决
问题继续
在执行UI块时引发异常:__NSCFNumber firstObject:无法识别的选择器已发送到实例0x9d7ca23b6657dd3d
编辑:我解决了我的问题,步骤:
1-使用CMD替代...使用CMD提示命令和窗口创建博览会项目以及所有依赖项和库... 不要使用PowerShell
2-安装react-native-svg-charts,react-native-chart-kit,react-native-svg-charts,使用“ expo instal ...”。不要使用添加纱线或npm安装
我希望这可以帮助每个人通过博览会创建图表。