Chartjs-Chart.js update is not a function

0👍

You should define a prop in your parent component for setting pie chart data. I assumed its name: setPieChartData

   const LatestSales = props => {
     const { setPieChartData, pieChartData} = props;

     const toggle = () =>{
        let $pieChartData = { ...pieChartData };
        $pieChartData.labels[0] = "teste"

        setPieChartData($pieChartData)
     }

     return (
        <>
           <button onClick={toggle}>toggle</button>
              <Doughnut
                 data={pieChartData}
                 options={pieChartOptions}
              />
        </>
     );
   };

Leave a comment