更新由:RNSVGPath InvalidNumber 管理的視圖的屬性“d”時如何解決錯誤
我需要使用 react-native-chart-kit 加載我的 SQL 服務器數據,但是當我使用此代碼時,我收到此錯誤:更新由以下人員管理的視圖的屬性“d”時出錯:RNSVGPath null InvalidNumberimport React from "react";import { Text, View, Dimensions } from "react-native";import { LineChart } from "react-native-chart-kit";export default class Home extends React.Component { constructor(props) { super(props); this.state = { isLoading: true, data: { labels: [ "Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic", ], datasets: [ { data: [], }, ], }, }; } GetData = () => { const self = this; return fetch("http://192.168.1.5:80/graph.php") .then((response) => response.json()) .then((responseJson) => { // clone the data from the state const dataClone = { ...self.state.data }; const values = responseJson.map((value) => value.ChiffreAffaire); dataClone.datasets[0].data = values; self.setState({ isLoading: false, data: dataClone, }); }) .catch((error) => { console.error(error); }); }; render() { return ( <View> <LineChart data={this.state.data} width={Dimensions.get("window").width} // from react-native height={220} yAxisLabel={"$"} chartConfig={chartConfig} bezier style={{ marginVertical: 8, borderRadius: 16, }} /> </View> ); }}我從我的 php 文件中獲得的數據如下:[{"ChiffreAffaire":"4800.00"},{"ChiffreAffaire":"12000.00"}]我不知道問題是什么以及為什么會出現此錯誤;請如果你有任何想法
查看完整描述