0

I'm creating a simple login form using react and redux form. When I try to console the values entered in the form, I get undefined.

    import React, { Component } from 'react';
    import { reduxForm } from 'redux-form';`enter code here`

    class Signin extends Component {
      handleFormSubmit({email, password}){
        console.log(email,password);
        // this.props.signinUser({email,password});
      }

      render(){
        const { handleSubmit, fields: { email, password }} = this.props;

        return (
          <form onSubmit={handleSubmit(this.handleFormSubmit.bind(this))}>
            <fieldset className="form-group">
              <label>Email:</label>
              <input className="form-control" {...email} />
            </fieldset>
            <fieldset className="form-group">
              <label>Password:</label>
              <input className="form-control" {...password}  />
            </fieldset>
            <button action="submit" className="btn btn-primary">Sign in</button>
          </form>
        );
      }
    }

    export default reduxForm({
      form: 'signin',
      fields: ['email', 'password']
    })(Signin);

1 Answer 1

1

I figured out the issue.

The tutorial I was following was one year old and was using an old version of Redux Form which accepts input in this form. But while installing the modules, I installed the latest version. Thanks.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.