我正在尝试使用图表工具包运行一个基本的React Native应用程序,我得到了这个错误: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',
},
});发布于 2020-02-08 04:14:03
修好了!!我正在为我的项目使用Expo,并且我使用npm安装了react-native-chart和react-native-svg。由于某种原因,我在使用nmp时遇到了这个错误,但在卸载它并使用"expo install“再次安装react-native-chart之后,一切都运行得很好。
发布于 2020-02-18 23:48:55
我有同样的问题,但没有解决使用"expo install install react-native-chart“
问题仍在继续
执行UI块时引发异常:__NSCFNumber firstObject:无法识别的选择器已发送到实例0x9d7ca23b6657dd3d
编辑:我解决了我的问题,步骤:
1-始终使用CMD ...使用CMD prompt命令和窗口创建expo-project和所有依赖项和库...请勿使用PowerShell
2-安装react-native-svg-charts、react-native-chart-kit、react-native-svg-charts、,使用"expo install.“请勿使用yarn add或npm install
我希望这能帮助每个人用expo创建图表……
https://stackoverflow.com/questions/60119860
复制相似问题