Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Super expression must either be null or a function, not undefined when using React-Sparklines

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!

like image 202
blankface Avatar asked Aug 10 '17 04:08

blankface


1 Answers

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

like image 150
NdalilaTony Avatar answered Sep 17 '22 23:09

NdalilaTony