Reactjs React Native-使用图表工具包时出错(执行UI块时引发异常:\uu NSCFNumber firstObject:发送到实例的无法识别的选择器)
我正在尝试使用图表工具包库运行基本的React本机应用程序,但收到以下错误: 有人知道怎么修吗 这是我的代码:Reactjs React Native-使用图表工具包时出错(执行UI块时引发异常:\uu NSCFNumber firstObject:发送到实例的无法识别的选择器),reactjs,react-native,react-native-chart-kit,Reactjs,React Native,React Native Chart Kit,我正在尝试使用图表工具包库运行基本的React本机应用程序,但收到以下错误: 有人知道怎么修吗 这是我的代码: import React from 'react'; import { View, StyleSheet } from 'react-native'; import { LineChart, Grid } from 'react-native-svg-charts'; class LineChartExample extends React.PureComponent { re
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',
},
});
从“React”导入React;
从“react native”导入{View,StyleSheet};
从“react native svg charts”导入{LineChart,Grid};
类LineChartExample扩展了React.PureComponent{
render(){
常数数据=[50,10,40,95,-4,-24,85,91,35,53,-53,24,50,-20,-80];
返回(
)
}
}
导出默认LineChartExample;
const styles=StyleSheet.create({
容器:{
弹性:1,
背景颜色:“#fff”,
对齐项目:“居中”,
为内容辩护:“中心”,
},
});
修复了它!!我在我的项目中使用Expo,我使用npm安装react-native图表工具包和react-native svg。出于某种原因,我使用nmp时出现了错误,但在卸载它并使用“expo install”重新安装react native chart kit后,一切正常。我也有同样的问题,但没有使用“expo install react native chart kit”解决
这个问题还在继续
执行UI块时引发异常:\uu NSCFNumber firstObject:发送到实例0x9d7ca23b6657dd3d的选择器无法识别
编辑:我解决了我的问题,步骤:
1-使用CMD aways。。。使用CMD提示符和windows创建您的expo项目以及所有从属项和库不要使用PowerShell
2-使用“expo instal…”安装react-native svg图表、react-native图表工具包、react-native svg图表。不要使用纱线添加或npm安装
我希望这能帮助大家用世博会制作图表