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.

Uncaught TypeError: Cannot read property 'chart' of undefined

See original GitHub issue

First of all, really nice job for wrapping highcharts as a react component, exactly what I’ve been looking for!

Following the instruction, I was able to get it up and run pretty easily. Everything works as expected, except the browser keeps throwing the following error whenever page reflows.

Uncaught TypeError: Cannot read property 'chart' of undefined
    hb.reflow @highcharts.js:222
    (anonymous function) @ReactHighcharts.js:1

Although it doesn’t seem to cause any real problem (the charts redraw without issue), I’d love to see a way to workaround the error. Here is the code for reference, which is pretty much the bare minimal for showing a line chart.

import React, {Component} from 'react';
import ReactHighcharts from 'react-highcharts';

export default class HighchartLine extends Component {
  constructor(props) {
    super(props);
  }

  render() {
    const config = {
      ...... // skipping the detail here for saving space
    };
    return (<ReactHighcharts config = {config} />);
  }
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
Matsemanncommented, Mar 30, 2016

We have a similar issue. For us it happens because the reflow-call inside requestAnimationFrame happens after componentWillUnmount, so checking if the chart still exists in the callback might be a good idea.

What triggers this in our case is that it mounts->unmounts->mounts quickly. If that is an error on our part I’m currently figuring out.

2reactions
Danitacommented, Apr 8, 2016

Yay it works perfectly now! Thanks a lot!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Highcharts 5: TypeError: Cannot read property 'chart' of ...
Problem is with the highcharts-ng library and I filed an issue report here: https://github.com/pablojim/highcharts-ng/issues/594.
Read more >
Cannot read property 'chart' of undefined - Highcharts
Everthing about the chart functions as it should except this error keeps getting thrown. I am recreating the chart on window resize and...
Read more >
TypeError: Cannot read property 'chart' of undefined at e.Chart ...
In line 57, I added a check ctrl!==undefined but the code still tries to execute the reflow , so at that point, ctrl...
Read more >
Chart.js: Uncaught TypeError: Cannot read property &#38;#039
This problem is not caused by our product. There's something wrong with Charts or Moment libraries, that the moment is undefined error is...
Read more >
Cannot read property 'chart' of undefined"-Highcharts
[Solved]-Vue Highcharts "TypeError: Cannot read property 'chart' of undefined"-Highcharts ... import Highcharts from 'highcharts';. You are using a named import.
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