reactjs / react-chartjs

common react charting components using chart.js
MIT License
2.93k stars 301 forks source link

this.state.chart is undefined at componentWillReceiveProps #176

Open alexfqc opened 7 years ago

alexfqc commented 7 years ago

classData.componentWillReceiveProps = function(nextProps) { var chart = this.state.chart; // can be undefined if (chart) { // if not undefined then do the action if (nextProps.redraw) { chart.destroy(); this.initializeChart(nextProps); } else { dataKey = dataKey || dataKeys[chart.name]; updatePoints(nextProps, chart, dataKey); if (chart.scale) { chart.scale.xLabels = nextProps.data.labels;

          if (chart.scale.calculateXLabelRotation){
        chart.scale.calculateXLabelRotation();
          }
      }
      chart.update();
    }
  }
};
joshi-mehul commented 6 years ago

@alex3165 it's in core.js right? please provide more data, where you're getting this? I have submitted pull request for this issue.

Jareechang commented 6 years ago

@alexfqc, could you please provide an example where this is occurring ? Thanks