question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Child redux-form component handleSubmit error.

See original GitHub issue

Hello everyone! I am facing an issue and whenever I try to render a redux form child component inside a parent component I get the error “handleSubmit is not a function”.

I am guessing that this could be caused because I am doing something wrong with the containers but let me describe the situation I am facing and maybe someone can help me.

I have a Parent component that includes 2 child components. One of the child components is a redux-form and the other one is a stateless functional component.

const Parent = ({ inputList }) => (
  <div>
    <MyForm />
    <MyList inputList={inputList} />
  </div>
);
export default Parent;

As I mentioned the MyList component is stateless so it has no container and I am just passing a prop to render a list. The Parent Component has a container ParentContainer like the following:

const mapStateToProps = state => (
  {
    inputList: state.get('inputList')
  }
);

const ParentContainer  = connect(mapStateToProps)(Parent);
export default ParentContainer;

The Form component is the following (don’t pay attention to the form tags since I am using reactstrap and that is not the issue):

const MyForm= ({ handleSubmit, submitSearch, submitting }) => (
  <span>
    <Form onSubmit={handleSubmit(submitSearch)}>
      <FormGroup row>
        <Col sm={2}>
          <Field
            id="itemCode"
            name="itemCode"
            component={inputField}
            type="text"
            placeholder="Search for Item"
          />
        </Col>
        <Col sm={2}>
          <Label for="dateFrom" sm={2}>Date From</Label>
          <Field
            id="dateFrom"
            name="dateFrom"
            component={inputField}
            type="text"
            placeholder="1/1/2016"
          />
        </Col>
        <Col sm={{ size: 2, offset: 1 }}>
          <Button type="submit" color="primary" disabled={submitting}>
            Search
          </Button>
        </Col>
      </FormGroup>
    </Form>
  </span>
);

export default MyForm;

The Form component also has a FormContainer:


const mapDispatchToProps = dispatch => (
  {
    submitSearch: (formSearchData) => {
      dispatch(searchItems(formSearchData));
    }
  }
);

const MySearchForm = reduxForm({
  form: 'mySearchForm'  // a unique identifier for this form
})(MyForm);

const MyFormContainer =
  connect(null, mapDispatchToProps)(MySearchForm);

export default MyFormContainer;

Now whenever I try to navigate to the Parent Component I get the error: “Uncaught TypeError: handleSubmit is not a function at MyForm (index.js:17)”

Any help would be really appreciated since I am stuck with this for some hours now…

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
gustavohenkecommented, Feb 10, 2017

You’re using <MyForm />, but your wrapped form is <MySearchForm>/<MyFormContainer>. Please check whether this is the problem.

0reactions
lock[bot]commented, Jun 1, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to access form errors in child component of decorated ...
I'm trying to understand why I can't access form errors in a child component rendered inside a decorated parent component.
Read more >
Declaring redux form in both the child and parent component ...
I was planning to put the forms into a separate component anyway, but wanted to solve the problem. So the bug is still...
Read more >
How to Trigger a Form Submit in Child Component with Redux
In this guide, we will learn how to trigger a form submission by dispatching an action from a component outside the form.
Read more >
props - Redux Form
A generic error for the entire form given by the _error key in the result from the synchronous validation function, the asynchronous validation,...
Read more >
Final Form Docs – Migration from Redux Form
Most of the config properties from Redux Form maps directly onto the props to ... and return errors object + }} > {()...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found