3π
I know itβs a little late but I was able to figure it out. I was using Recoil js and it was giving me the same problem when trying to update the data array from global statemanagement. My solution was to create a copy from the piece of state I was updating and just pass that to the data.
Something like this:
const [dataPoints, setDataPoints] = useRecoilState(dataPointFetch);
const dataPointsArrayCopy = [...dataPoints]
const chartData = {
labels: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
datasets: [
{
label: `Jobs applied this day`,
data: dataPointsArrayCopy,
borderColor: ["rgba(16, 142, 233,0.8)"],
pointBackgroundColor: "rgba(16, 142, 233,0.8)",
fill: false,
borderWidth: 4
}
]
};
Source:stackexchange.com