question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError after unmounting chart

See original GitHub issue

I 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:open
  • Created 10 months ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
Roblochecommented, Dec 20, 2022

@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

1reaction
Roblochecommented, Dec 9, 2022

Yes, that’s obviously what I did. But that’s not sustainable.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found