React Native 在尝试使用 Victory 图表组件时出现组件异常错误

React Native giving a Component Exception error when trying to use Victory chart component

所以我正在尝试使用 Victory 库来响应本机,以便为我的预算应用程序绘制折线图。这是我的图形组件中的代码

import React from 'react';
import { View, StyleSheet } from 'react-native';
import { VictoryLine } from 'victory';

export default function Graph() {
    return (
        <View>
            <VictoryLine />
        </View>
        
        
    )
}

这是组件导入位置的代码

import React from 'react'
import { View, Text, StyleSheet, TextInput } from 'react-native'
import Graph from './Line'

export default function MonthSummary() {
    return (
        <View style={styles.container}>
            <Text style={styles.title}>My Summary</Text>
            <Text style={styles.subtitle}>£1,325</Text>
            <Graph />
        </View>
    )

}

const styles = StyleSheet.create({
    container: {
        backgroundColor: 'white',
        width: 350,
        height: 200,
        padding: 20,
        shadowColor: "#000",
        shadowOffset: {
            width: 0,
            height: 2,
        },
        shadowOpacity: 0.25,
        shadowRadius: 3.84,
        elevation: 5,
    },
    title: {
        textTransform: 'uppercase',
        fontSize: 14,
        fontWeight: '600',
        color: '#333333',
    },
    subtitle: {
        color: '#333333',
        fontSize: 30,
        marginTop: 5,
    }
  });

但是当我 运行 我的应用程序出现组件异常错误时。 Screenshot here。如果有人能提供帮助那就太好了,因为我已经为此苦苦挣扎了几个小时!

您似乎在使用网络库而不是 React Native 库。按照 this 进行设置并将图表组件更改为如下所示

import React from 'react';
import { View, StyleSheet } from 'react-native';
import { VictoryLine } from 'victory-native';

export default function Graph() {
    return (
        <View>
            <VictoryLine />
        </View>
        
        
    )
}