I have installed react-chartjs. When following the instructions to test it I get an error cannot read property 'Chart' of undefined' at line 10 Chart.js
here is my code
var React = require('react');
var Chart = require('chart.js');
var LineChart = require("react-chartjs").Line;
var LineChart = React.createClass({
render: function() {
return <LineChart width="600" height="250"/>
}
});
module.exports = LineChart;
Im stumped and cannot find any solutions online. Thanks for any comments
You are declaring LineChart
twice. Change the name of one of them, for example:
var MyChart = React.createClass({ /* rest of your code */ });
module.exports = MyChart;
I also have the same issue, and 'npm cache clean' helps! It may related to the dependency of chartjs & react-chartjs.
I had the same problem. Exclusion of node_modules in Webpack build helped. Look at this https://github.com/jhudson8/react-chartjs/issues/93 .
Here's an example "module" section of webpack.config.js
:
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules)/,
loader: 'babel-loader'
}
]
}
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.