Javascript 如何修复代码中的“`render`在返回的组件实例上找到的方法”错误?

Javascript 如何修复代码中的“`render`在返回的组件实例上找到的方法”错误?,javascript,reactjs,react-redux,Javascript,Reactjs,React Redux,出于某种原因,我的React组件显示此错误: Warning: ReactComponent(...): No `render` method found on the returned component instance: you may have forgotten to define 'render'. 即使我已在组件中定义了渲染: import React, { Component } from 'react'; import {addCart} from './Shop'; im

出于某种原因,我的React组件显示此错误:

Warning: ReactComponent(...): No `render` method found on the returned component instance: you may have forgotten to define 'render'.
即使我已在组件中定义了渲染:

import React, { Component } from 'react';
import {addCart} from './Shop'; 
import { connect } from 'react-redux';


export class Cart extends Component {
    render() {
        console.log('cart', this.props.cart);
        return(
            <div className= "Webcart" id="Webcart">
                <Component cartItem={this.props.cartItem} />
            </div>
        );
    }
}

const mapDispatchToProps = (dispatch) => {
    return {
        onCartAdd: (cart) => {
            dispatch(addCart(cart));
        },
    }
}

function mapStateToProps(state) {
  return { cart: state.cart };
}

export default connect(mapStateToProps, mapDispatchToProps)(Cart);
我的组件有什么问题导致了此错误?

这一行就在这里:

<Component cartItem={this.props.cartItem} />
这里组件指的是React.Component,或者您在错误消息中看到的ReactComponent,它没有实现呈现方法,它只是组件的超类。您正在尝试创建组件的元素,但该元素没有渲染方法,也没有任何意义

您可能使用了错误的组件,并且忘记导入和使用正确的组件