Chartjs-React & Chartjs: How can I best destroy my chart when re-rendering?

0👍

My solution:

  1. Declare chart variable outside of class component
  2. Run the build chart fn on both componentDidMount & componentDidUpdate
  3. In each build call the destroy() method on the chart variable if not undefined

Found the solution here: https://blog.bitsrc.io/customizing-chart-js-in-react-2199fa81530a

Leave a comment