【发布时间】:2018-01-18 04:09:01
【问题描述】:
我正在为一个项目使用第三方组件 react-sparklines。但是,当我将其导入到我的组件中时,如下所示,它会引发以下错误:Uncaught TypeError: Super expression must be null or a function, not undefined。但是当我取出它时,错误消失了,应用程序运行顺利。
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() 函数。这是 Sparklines 的链接:https://github.com/borisyankov/react-sparklines
任何帮助将不胜感激!
【问题讨论】:
标签: reactjs react-redux