1👍
✅
You don’t have a labels array, in your data object you have a datasets
key and a lables
key, this last one is wrong, it is supposed to be labels
. If you change it to that it will work:
const [chartData, setChartData] = useState({
labels: dates,
datasets: [{
label: "value of BTC in ILS",
data: coinValue,
backgroundColor: 'gold'
}]
})
Same for the lable
key in the dataset, it is supposed to be label
-1👍
You are writing the spelling of label
and labels
incorrect, it should be label
rather than lable
and labels
rather than lables
. And what other thing I would suggest is wrap you Line component in an condition, like
...other code
{ dates.length > 0 &&
<Line data = {chartData} />
}
...other code
This would simply wait for the api call and the dates
state to change.
Source:stackexchange.com