Check the render method of `ConnectedField`

[亡魂溺海] 提交于 2020-05-29 05:06:05

问题


I am getting this error message when i used a redux-form into my simple three input fields 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 is already working so i have not include them in the code. And has already defined a Provider store in index.js file.


回答1:


You haven't specified the required component property of your Field, it should be:

<Field 
   type="text" 
   className="trans login_input" 
   title="Username" 
   name="username" 
   placeholder="Username" 
   component="input"  
/>

Check here for docs




回答2:


I think you are incorrectly connecting your component to redux, try this, Ref

Signup = connect(
    mapStateToProps,
    mapDispatchToProps
)(Signup);

export default reduxForm({
    form: 'Signup'
})(Signup);


来源:https://stackoverflow.com/questions/56053997/check-the-render-method-of-connectedfield

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!