我正在开发服务器端渲染的react.js应用程序。我正在使用reduxForm作为注册组件。 但是我在控制台中遇到了波纹管错误
警告:React.createElement:类型无效-预期为字符串 (对于内置组件)或类/函数(对于复合 组件),但得到:未定义。您可能忘记了导出 定义文件中的组件,否则您可能混淆了 默认导入和命名导入。
"react-redux": "^5.0.7",
"react-router": "^4.3.1",
"redux-form": "^7.4.2"
import React, { Component } from 'react';
import { connect } from "react-redux";
import { Field, reduxForm } from "redux-form";
class SignUpForm extends Component {
constructor(props) {
super(props);
this.renderField = this.renderField.bind(this);
}
renderField(field) {
const { meta: { touched, error } } = field;
const className = `form-group ${touched && error ? "has-danger" : ""}`;
return (
<div className={className}>
<label>{field.label}</label>
<input className="form-control" type={field.type || "text"} {...field.input} />
<div className="text-help">
{touched ? error : ""}
</div>
</div>
);
}
render() {
const { handleSubmit } = this.props;
return (
<form >
<Field
label="Mobile Number"
name="mobilenumber"
component={this.renderField}
/>
<button type="submit" className="btn btn-primary btn-play">OK</button>
</form>
);
}
}
function mapDispatchToProps(dispatch) {
return bindActionCreators({ signup }, dispatch);
}
export default reduxForm({
validate,
form: "SignUpForm"
})(connect(null, mapDispatchToProps)(SignUpForm));