Reputation: 440
I want to import this package.
The link only provide this example
var LineChart = require("react-chartjs").Line;
var MyComponent = React.createClass({
render: function() {
return <LineChart data={chartData} options={chartOptions} width="600" height="250"/>
}
});
but how to import like this
import {LineChart } from 'react-chartjs';
I can not figure out how to
.Line;
in import style
Upvotes: 3
Views: 194
Reputation: 6944
Given the answer from oxy_js, I believe the import line you want is
import { Line as LineChart } from 'react-chartjs';
This is import Line
but alias it as LineChart
for use in this file.
Upvotes: 2
Reputation: 2112
You can write
import Line from 'react-chartjs';
Because in index.js
of react-chartjs
Line is listed as
module.exports = {
Bar: require('./lib/bar'),
Doughnut: require('./lib/doughnut'),
Line: require('./lib/line'),
Pie: require('./lib/pie'),
PolarArea: require('./lib/polar-area'),
Radar: require('./lib/radar'),
createClass: require('./lib/core').createClass
};
And then use {Line}
when you need.
Upvotes: 2
Reputation: 12093
var LineChart = require("react-chartjs").Line;
Equivalent
import Line from 'react-chartjs/lib/line';
Upvotes: 3