当我在简单的三个输入字段表单中使用 redux-form 时,我收到此错误消息。
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 The SingupAction
and handleSignup
已经在工作了,所以我没有将它们包含在代码中。
并且已经定义了一个Provider store
in index.js
file.
您还没有指定所需的内容component
你的财产Field
, 它应该是:
<Field
type="text"
className="trans login_input"
title="Username"
name="username"
placeholder="Username"
component="input"
/>
Check here https://redux-form.com/8.2.0/docs/api/field.md/#-code-component-component-lt-fieldprops-gt-string-code-required-对于文档
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)