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.

Failed prop type: Invalid prop `form` of type `object` supplied to `Form(App)`, expected `string`

See original GitHub issue

I have the following form: It’s almost same as Simple Form.

import React from 'react'
import { Field, reduxForm } from 'redux-form'

const App = (props) => {
  const { handleSubmit, pristine, reset, submitting } = props
  return (
    <form onSubmit={handleSubmit}>
      <div>
        <label>First Name</label>
        <div>
          <Field name="firstName" component="input" type="text" placeholder="First Name"/>
        </div>
      </div>
      <div>
        <label>Last Name</label>
        <div>
          <Field name="lastName" component="input" type="text" placeholder="Last Name"/>
        </div>
      </div>
      <div>
        <label>Email</label>
        <div>
          <Field name="email" component="input" type="email" placeholder="Email"/>
        </div>
      </div>
      <div>
        <label>Sex</label>
        <div>
          <label><Field name="sex" component="input" type="radio" value="male"/> Male</label>
          <label><Field name="sex" component="input" type="radio" value="female"/> Female</label>
        </div>
      </div>
      <div>
        <label>Favorite Color</label>
        <div>
          <Field name="favoriteColor" component="select">
            <option></option>
            <option value="ff0000">Red</option>
            <option value="00ff00">Green</option>
            <option value="0000ff">Blue</option>
          </Field>
        </div>
      </div>
      <div>
        <label htmlFor="employed">Employed</label>
        <div>
          <Field name="employed" id="employed" component="input" type="checkbox"/>
        </div>
      </div>
      <div>
        <label>Notes</label>
        <div>
          <Field name="notes" component="textarea"/>
        </div>
      </div>
      <div>
        <button type="submit" disabled={pristine || submitting}>Submit</button>
        <button type="button" disabled={pristine || submitting} onClick={reset}>Clear Values</button>
      </div>
    </form>
  )
}

export default reduxForm({
  form: 'app'  // a unique identifier for this form
})(App)

I get the following error:

warning.js:36Warning: Failed prop type: Invalid prop `form` of type `object` supplied to `Form(App)`, expected `string`.
    in Form(App) (created by Connect(Form(App)))
    in Connect(Form(App)) (created by ReduxForm)
    in ReduxForm (created by Connect(ReduxForm))
    in Connect(ReduxForm) (at index.js:12)
    in Provider (at index.js:11)

I checked the prop of the Connect(Form(App)). 2016-12-25 12 04 56

Why is the prop ‘form’ recognized as Object (not string)? And I want to know how to solve this problem.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

11reactions
chanancommented, Jan 23, 2017

Never mind, found the answer 😃 in my case one of my props was also named “form”, renamed it to something else.

2reactions
fbownzcommented, Jan 12, 2018

I had the same issue.

I found a way around it by using a different property name other than ‘form’ on mapStatetoProps

const mapStateToProps = state => {
	return {
		neworderdata: state.neworderdata,
		default_paper_type: state.prospect.prospect_paper_type,
		page: state.neworder_page,
		ordercost: state.ordercost,
		auth: state.auth,
		top_writers: state.topwriters,
		neworder: state.neworder
		// form: state.form 
               //Changed this to a different name from form and it worked
	};
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Warning: Failed prop type: Invalid prop `label` of type `object ...
It means you're providing the wrong type to the label prop. It only expects a string, but you're passing a react fragment. Change...
Read more >
invalid prop `rows` of type `object` supplied to `forwardref ...
I am using react-native-snap-carousel, It worked fine, It fetches data fine but i am getting 2 warnings in that app. Warning: Failed prop...
Read more >
Warning: Failed prop type: Invalid prop `children` supplied to ...
Warning: Failed prop type: Invalid prop `children` supplied to `ForwardRef(Typography)`, expected a ReactNode. */<Typography key={item.id}>
Read more >
Warning: Invalid prop `renderChatItem` - Sendbird Community
This looks like a wrong prop type given to the renderChatItem prop on our side, that expects a React Element instead of a...
Read more >
prop-types - npm
You might also see this error if you're calling a PropTypes validator from your own custom PropTypes validator. In this case, the fix...
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