score:3

Accepted answer
    const EmailForm = (props) => {
      const { handleSubmit } = props;
      return (
        <form onSubmit={handleSubmit} >
          <div>
            <label htmlFor="firstName">First Name</label>
            <Field name="firstName" component="input" type="text" />
          </div>
          <div>
            <label htmlFor="lastName">Last Name</label>
            <Field name="lastName" component="input" type="text" />
          </div>
          <div>
            <label htmlFor="email">Email</label>
            <Field name="email" component="input" type="email" />
          </div>
          <button type="submit">
            Submit
          </button>
        </form>
      );
    };

        export default reduxForm({
         onSubmit: submitFunction,  /*this is the place where you need to pass Submit function object*/
          form: 'contact',

        })(EmailForm);

    const submitFunction =(formValues, dispatch)=>{
       /*send formValues to api....or dispatch submit action with 
       formValues*/
      }

score:2

import React from 'react';
import { Field, reduxForm } from 'redux-form';
import { PropTypes } from 'prop-types';


const EmailForm = (props) => {
  const { handleSubmit, submitForm } = props;
  return (
    <form onSubmit={handleSubmit(submitForm)}>
      <div>
        <label htmlFor="firstName">First Name</label>
        <Field name="firstName" component="input" type="text" />
      </div>
      <div>
        <label htmlFor="lastName">Last Name</label>
        <Field name="lastName" component="input" type="text" />
      </div>
      <div>
        <label htmlFor="email">Email</label>
        <Field name="email" component="input" type="email" />
      </div>
      <button type="submit">
        Submit
      </button>
    </form>
  );
};

export default reduxForm({
  // a unique name for the form
  form: 'contact',
  // fields: ['firstName', 'lastName', 'email'],
})(EmailForm);

EmailForm.propTypes = {
  handleSubmit: PropTypes.func.isRequired,
};

Related Query

More Query from same tag