gpt4 book ai didi

reactjs - 使用 React-Sparklines 时, super 表达式必须为 null 或函数,不能为未定义

转载 作者:行者123 更新时间:2023-12-03 13:21:20 31 4
gpt4 key购买 nike

我正在为项目使用第三方组件react-sparklines。但是,当我将其导入到我的组件时,如下所示,它会抛出以下错误:未捕获类型错误: 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() 函数。以下是迷你图的链接:https://github.com/borisyankov/react-sparklines

任何帮助将不胜感激!

最佳答案

迷你图 1.7.0 版本有一个错误。考虑降级到较低版本,在本例中为版本 1.6.0:

npm r react-sparklines
npm i --save react-sparklines@1.6.0

您可能想在此处获取更多信息:https://github.com/borisyankov/react-sparklines/issues/89

关于reactjs - 使用 React-Sparklines 时, super 表达式必须为 null 或函数,不能为未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45604732/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com