简体   繁体   中英

react-chartjs gives back a type error : (intermediate value)[chartType] is not a function

when i run the server..this component is loaded ...no errors found on server side...but browser console gives back a following error :

Uncaught TypeError: (intermediate value)[chartType] is not a function

my code is as follows :

var React = require('react');
var ReactDOM = require('react-dom');
var chart = require('chart.js');
var DoughnutChart = require("react-chartjs").Doughnut;
var Tempvshum = React.createClass({
  render() {
    var chartOptions = {
    segmentShowStroke : true
  };
var chartData = [{
    value: 300,
    color:"#F7464A",
    highlight: "#FF5A5E",
    label: "Red"
  }];
   return(<DoughnutChart data={chartData} options={chartOptions} />);
   }
  });
module.exports = Tempvshum;

I think the issue is related to chart.js.

https://www.npmjs.com/package/chart.js says that the package has been uploaded 2 days ago and it is now in version 2.0.0-beta2. I modified my package.json to use the older version 1.1.1 and everything works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM