TypeError after unmounting chart
See original GitHub issueI have a <Line> chart in my React app.
Since I updated chart.js to v4.0.1, I get the following error when I unmount my chart:
Uncaught TypeError: Cannot set properties of null (setting '_setStyle')
    at chartjs-plugin-streaming.esm.js:787:1
    at each (helpers.core.ts:149:1)
    at Chart.update (chartjs-plugin-streaming.esm.js:785:1)
    at chartjs-plugin-streaming.esm.js:601:1
    at callback (helpers.core.ts:109:1)
    at chartjs-plugin-streaming.esm.js:68:1
This error is triggered repeatedly and infinitely. It seems that some kind of timer has not been cleared.
Here’s my code:
<Line
  data={{datasets}}
  options={{
    scales: {
      x: {
        display: false,
        realtime: {
          delay: 1000,
          onRefresh: (chart) => {
            const x = Date.now();
            const y = getY();
            chart.data.datasets.forEach((dataset, i) => {
              dataset.data.push({
                x,
                y: y[i]
              });
            });
          }
        },
        type: 'realtime'
      },
      y: yOptions
    }
  }} />
Issue Analytics
- State:
 - Created 10 months ago
 - Comments:8
 
Top Results From Across the Web
wrapper.instance() throws error after wrapper.unmount() #956
When calling wrapper.instance() after wrapper.unmount() it throws TypeError: component.getPublicInstance is not a function.
Read more >Highmaps React - destroy() throws exceptions on unmount
When I conditionally mount / unmount a component, I want to handle the chart reference and ensure the chart reference is correctly disposed....
Read more >TypeError: Cannot read property 'length' of null in react ...
FAIL lib\chart\chart.test.tsx ○ renders without crashing TypeError: Cannot read property 'length' of null at Object.
Read more >Fix the "Uncaught TypeError: destroy is not a function" Error in ...
It turns out this almost always happens when you try to return anything from your useEffect hook that is not a function.
Read more >nextjs typeerror: cannot read properties of undefined (reading ...
Hi, I'm developing a modal window with an integrated leaflet map and I'm facing the same problem. When unmounting the modal window from...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@Dola97 If you’re still interested, I forked the project and fixed this issue. I also bumped all dependencies versions.
https://www.npmjs.com/package/@robloche/chartjs-plugin-streaming
Yes, that’s obviously what I did. But that’s not sustainable.