当我在我的简单三个输入字段表单中使用redux表单时,收到此错误消息。
form.jsx
import React, {Component} from 'react';
import { Field, reduxForm } from 'redux-form'
import { connect } from 'react-redux';
class Signup extends Component {
signupView = () => {
return (
<section id="user_login">
<form onSubmit={this.handleSignup}>
<ul>
<li>
<div className="custom_group">
<Field type="text" className="trans login_input" title="Username" name="username" placeholder="Username" />
</div>
</li>
<li className="sbt_btn">
<button className="trans white_bg">SIGN UP</button>
</li>
</ul>
</form>
</section>
)
}
render() {
return (
<div>{this.signupView()}</div>
)
}
}
const mapStateToProps = (state) => {
return {
isRegistered: state.signup.isRegistered,
};
}
const mapDispatchToProps = dispatch => ({
SingupAction: (signupInput) => { dispatch(SingupAction(signupInput)) },
})
const formWrapped = reduxForm({
form: 'Signup'
})(Signup);
export default connect(mapStateToProps, mapDispatchToProps)(formWrapped);
P.S SingupAction
和handleSignup
已经在工作,因此我没有在代码中包含它们。
并且已经在Provider store
文件中定义了index.js
。
答案 0 :(得分:2)
您尚未指定component
的必需Field
属性,它应该是:
<Field
type="text"
className="trans login_input"
title="Username"
name="username"
placeholder="Username"
component="input"
/>
检查here中的文档
答案 1 :(得分:0)
我认为您将组件错误地连接到redux
,请尝试使用Ref
Signup = connect(
mapStateToProps,
mapDispatchToProps
)(Signup);
export default reduxForm({
form: 'Signup'
})(Signup);