获取未捕获的TypeError:超级表达式必须为null或函数,而不是未定义

时间:2018-06-03 13:50:41

标签: reactjs antd

下面是我的loginForm.js,我怀疑错误源自: -

import { Form, Icon, Input, Button, Checkbox } from 'antd';
const FormItem = Form.Item;
import React, { Component } from 'react';

class NormalLoginForm extends Component {
  handleSubmit = (e) => {
    e.preventDefault();
    this.props.form.validateFields((err, values) => {
      if (!err) {
        console.log('Received values of form: ', values);
      }
    });
  }
  render() {
    const { getFieldDecorator } = this.props.form;
    return (
      <Form onSubmit={this.handleSubmit} className="login-form">
        <FormItem>
          {getFieldDecorator('userName', {
            rules: [{ required: true, message: 'Please input your username!' }],
          })(
            <Input prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />} placeholder="Username" />
          )}
        </FormItem>
        <FormItem>
          {getFieldDecorator('password', {
            rules: [{ required: true, message: 'Please input your Password!' }],
          })(
            <Input prefix={<Icon type="lock" style={{ color: 'rgba(0,0,0,.25)' }} />} type="password" placeholder="Password" />
          )}
        </FormItem>
        <FormItem>
          <Button type="primary" htmlType="submit" className="login-form-button">
            Log in
          </Button>
          Or <a href="">register now!</a>
        </FormItem>
      </Form>
    );
  }
}

const WrappedNormalLoginForm = Form.create()(NormalLoginForm);

export default WrappedNormalLoginForm;

下面是我加载句柄路由的主要组件文件: -

import React, { Component } from 'react';
import { BrowserRouter, Route } from 'react-router-dom';
import WrappedNormalLoginForm from './loginForm'

export default class App extends Component {
  render() {
    return (
    <div className="container">
        <BrowserRouter>
          <div>
              <Route exact path="/" component={WrappedNormalLoginForm} />
          </div>
        </BrowserRouter>
    </div>
    );
  }
}

我无法解决此问题。我已经使用大写C进行了扩展,这被提到作为许多问题的解决方案。

0 个答案:

没有答案