Chartjs-How to update Chartjs in Reactjs?

0👍

In useEffect() the second parameter (i.e. the []) which is an array of properties to be observed within the scope of the stateless component. Whenever any of them are updated, the function is executed again. So add chart into the empty array.

0👍

Also don’t forget to put redraw parameter in your chart:

<Line data={chartData} redraw={true}/>

This will allow the chart to update and be redrawn.

Leave a comment