Zer*_*rty 9 reactjs react-redux
我正在为项目使用第三方组件react-sparklines.但是,当我将它导入我的组件时,如下所示,它会抛出以下错误:未捕获TypeError:超级表达式必须为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);
Run Code Online (Sandbox Code Playgroud)
请注意我故意遗漏了这个render()功能.这是Sparklines的链接:https://github.com/borisyankov/react-sparklines
任何帮助将不胜感激!
小智 30
Sparklines版本1.7.0有一个错误.考虑降级到较低版本,在本例中为1.6.0版本:
npm r react-sparklines
npm i --save react-sparklines@1.6.0
Run Code Online (Sandbox Code Playgroud)
您可能希望在此处获取更多信息:https://github.com/borisyankov/react-sparklines/issues/89
| 归档时间: |
|
| 查看次数: |
3666 次 |
| 最近记录: |