我正在使用第三方组件react项目的火花线。但是,当我将它导入到我的组件时(如下图所示),它会引发以下错误:Uncaught : Super必须为null或函数,而不是未定义的。但是当我把它拿出来的时候,错误就消失了,应用程序也运行得很顺利。
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);请注意,我故意忽略了render()函数。下面是到Sparkline的链接:https://github.com/borisyankov/react-sparklines
任何帮助都将不胜感激!
发布于 2017-08-10 22:31:39
Sparkline的1.7.0版本有一个bug。考虑降级到更低的版本,在本例中是1.6.0版本:
npm r react-sparklines
npm i --save react-sparklines@1.6.0您可能想在这里获得更多信息:https://github.com/borisyankov/react-sparklines/issues/89
发布于 2017-08-10 05:30:57
您需要在类中定义构造函数。
constructor(props){
super(props);
}https://stackoverflow.com/questions/45604732
复制相似问题