Chartjs-React passing a variable object to setState vs. an anonymous object to setState

0👍

One thing I noticed is that state.chartData.datasets is an array, but in setChartData you’re setting data on the array not one of its elements.

This:

chartDataUpdate['datasets'].data = hours;

Should be:

chartDataUpdate['datasets'][0].data = hours;

Leave a comment