无法读取未定义的属性“ createElement”

时间:2019-10-10 22:12:26

标签: javascript reactjs react-redux

我的React应用遇到一些问题。 我正在实现功能authUser,现在收到如下错误:

  

TypeError:无法读取未定义的属性'createElement'

并且在返回(..

这是我的代码

import { React, Component } from "react";
import Widget from "components/Widget/index";
import { Badge, Button, Col, Row } from "antd";
import { Link } from "react-router-dom";
import { connect } from "react-redux";
import { userSignOut } from "appRedux/actions/Auth";
import LineIndicator from "./LineIndicator";


class Portfolio extends Component {

  render() {
    const { authUser } = this.props;

    return (
      <Widget>
        <h2 className="h4 gx-mb-3">Your Portfolio Balance</h2>
        <Row>
          <Col lg={12} md={12} sm={12} xs={24}>

            <div className="ant-row-flex">
              <h2 className="gx-mr-2 gx-mb-0 gx-fs-xxxl gx-font-weight-medium">$179,626</h2>
            </div>
            <p className="gx-text-grey"></p>
            <div className="ant-row-flex gx-mb-3 gx-mb-md-2">
              <Button className="gx-mr-2" type="primary">Deposit</Button>
              <Button className="gx-btn-cyan">Withdraw</Button>
            </div>
            <p><Link className="gx-text-primary" to="/te">- Messages <Badge count={23} style={{ backgroundColor: '#52c41a' }} /></Link></p>
            <p><Link className="gx-text-primary" to="/te">- Notifications <Badge count={320} style={{ backgroundColor: '#52c41a' }} /></Link></p>
            <p><Link className="gx-text-primary" to="/te">- Active Servers <Badge count={5} style={{ backgroundColor: '#52c41a' }} /></Link></p>
            <p><Link className="gx-text-primary" to="/te">- Billing </Link></p>
            <p><Link className="gx-text-primary" to="/te">- Logout </Link></p>


          </Col>
          <Col lg={12} md={12} sm={12} xs={24}>
            <div className="gx-site-dash">
              <h4 className="gx-mb-3">Welcome back {authUser ? authUser.name : "Loading"}</h4>
              <img alt="" width="160" src={require("assets/images/w-logo.png")} />
            </div>
          </Col>
        </Row>
      </Widget>
    )
  }
}

const mapStateToProps = ({ auth }) => {
  const { authUser } = auth;
  return { authUser }
};

export default connect(mapStateToProps, { userSignOut })(Portfolio);

我在做什么错了?

1 个答案:

答案 0 :(得分:3)

我认为您导入的React错误

import { React, Component } from "react";

应该是这个

import React, {Component} from "react";