Reputation: 6347
I'm using the third party component react-sparklines for a project. However, when I import it to my component as shown below it throws the following error: Uncaught TypeError: Super expression must either be null or a function, not undefined. But when I take it out, the error goes away and the app runs smoothly.
import React, {Component} from 'react';
import {connect} from 'react-redux';
import { Sparklines, SparklinesLine } from 'react-sparklines';
class WeatherList extends React.Component{
renderCity(cityData){
const name = cityData.city.name;
const temps = cityData.list.map(weather => weather.main.temp);
return (
<tr key={name}>
<td>{name}</td>
<td>
<Sparklines data={[5, 10, 5, 20]}>
<SparklinesLine color="blue" />
</Sparklines>
</td>
</tr>
);
}
}
function mapStateToProps(state){
return { weather: state.weather };}
export default connect(mapStateToProps)(WeatherList);
Please note I knowingly left out the render()
function. Here's the link to Sparklines: https://github.com/borisyankov/react-sparklines
Any help will be appreciated!
Upvotes: 9
Views: 3919
Reputation: 441
Version 1.7.0 of Sparklines has a bug. Consider downgrading to a lower version, in this case version 1.6.0:
npm r react-sparklines
npm i --save [email protected]
You might want to get more information here: https://github.com/borisyankov/react-sparklines/issues/89
Upvotes: 30
Reputation: 764
you need to define constructor in your class.
constructor(props){
super(props);
}
Upvotes: -3