1

I am trying to integrate redux-form (Ver 5.25) into my react.js based web app, but I run into the following problem with the simple sync validation redux-form example:

Uncaught (in promise) Error: Element type is invalid: expected a string 
(for built-in components) or a
 class/function (for composite components) but got: undefined.

Code:

<Field name="username" component = {username =>
  <div>
    <input type="text" {...username} placeholder="Username"/>
    {username.touched && username.error && <span>{username.error}</span>}
  </div>
}/>

In the custom form component (UserRegistrationForm), I have the following code:

export default reduxForm({
    form: 'registrationForm',
    fields,
    validate,
})(UserRegistrationForm);

And in my root reducers, I mounted redux-form reducer to form:

form: formReducer,  // redux-form mounted at 'form'

So I was wondering what caused the error with the example code above. I guess the component part in Field is causing it, but I've no idea how to fix it. Any help is appreciated!

Edit: An appropriate example for using the Field component is here with material-ui, which I am trying to do something similar to

2
  • Where is <Field> component declared? Commented Jun 18, 2016 at 13:53
  • There's an import for it: import { Field } from 'redux-form'; Commented Jun 18, 2016 at 20:25

1 Answer 1

1

I don't think you can do

import { Field } from 'redux-form'

Doesn't seem like that is exported from that package. That's why you're getting that exception, as Field is undefined. I'm not sure what it is you're trying to do with redux-form, I don't see anything like what you're doing in the tutorial you linked to.

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

4 Comments

thanks, but there's this example using Field component: redux-form.com/6.0.0-alpha.7/examples/material-ui
That example is for the 6.0.0 version though, not the 5.25 version. 6.0.0 has Field, but it's new for that and it's still in alpha: github.com/erikras/redux-form/releases
Yes, you are mixing syntax between v5 and v6.
i'm on 8.2.0 and getting this same error when using Field.

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.