3

我尝试使用 Chart Kit 库运行基本的 React Native App 我收到此错误: 单击图像:执行 UI 块时引发异常:__NSCFNumber firstObject:无法识别的选择器发送到实例 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',
  },
});
4

2 回答 2

2

解决它!!我在我的项目中使用 Expo,我使用 npm 安装 react-native-chart-kit 和 react-native-svg。出于某种原因,使用 nmp 我得到了错误,但是在卸载它并使用“expo install”之后,再次安装 react-native-chart-kit,一切正常。

于 2020-02-07T20:14:02.737 回答
1

我有同样的问题,但没有使用“expo install install react-native-chart-kit”解决

问题继续

执行 UI 块时抛出异常:__NSCFNumber firstObject:无法识别的选择器发送到实例 0x9d7ca23b6657dd3d

编辑:我解决了我的问题,步骤:

1 - 使用 CMD aways...使用 CMD 提示命令窗口创建您的 expo-project 和所有依赖项和库...不要使用 PowerShell

2 - 安装 react-native-svg-charts、react-native-chart-kit、react-native-svg-charts, 使用“expo instal ....”不要使用yarn add 或 npm install

我希望这可以帮助每个人用expo创建图表......

于 2020-02-18T15:48:55.230 回答