我有一个react组件,用于显示带有highstock的图表,我想给他一个数组作为参数来显示图表中的值。问题是当我在componentDidMount中调用setState方法时,Highstock组件会引发错误。 错误是:
TypeError: Cannot read property 'hoverSeries' of undefined
at q.destroy (highstock.js:285)
at q.c.destroy (highstock.js:412)
at g (highstock.js:315)
at a.fireEvent (highstock.js:30)
at q.remove (highstock.js:315)
at eval (highstock.js:311)
at Array.forEach (<anonymous>)
at a.each (highstock.js:28)
at a.Chart.update (highstock.js:311)
at a.Chart.eval (highstock.js:501)
当我不使用this.setState时,我可以显示图表。我还尝试将选项卡直接传递给状态:
this.state.myTab = tab
但是它没有用(渲染器没有考虑到它)。