Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage with redux forms: Value error on multiple selection #185

Open
saranshbansal opened this issue Oct 22, 2018 · 0 comments
Open

Usage with redux forms: Value error on multiple selection #185

saranshbansal opened this issue Oct 22, 2018 · 0 comments

Comments

@saranshbansal
Copy link

saranshbansal commented Oct 22, 2018

I was able to make it work with redux form. However, there is one problem. As you mentioned:
if multiple is set, value must be at least an empty Array.

I'm not able to achieve it. The value and onSelect are handled by redux-forms. The defaults for value is null. When I run my example, I get the error saying that value must be an array.

console.js?32ad:35 Warning: Failed prop type: 
          When using 'multiple' mode, 'value' of 'SelectField undefined' must be an array.
    in SelectField (created by AutoCompleteFormField)
    in AutoCompleteFormField (created by AccountHolderSelectFormField)
    in div (created by AccountHolderSelectFormField)
    in AccountHolderSelectFormField (created by Connect(AccountHolderSelectFormField))
    in Connect(AccountHolderSelectFormField) (created by ConnectedField)
    in ConnectedField (created by Connect(ConnectedField))
    in Connect(ConnectedField) (created by Field)
    in Field (created by BookingsExportFilterForm)
    in form (created by BookingsExportFilterForm)
    in div (created by DialogInline)
    in div (created by Paper)
    in Paper (created by DialogInline)
    in div (created by TransitionItem)
    in TransitionItem (created by TransitionGroup)
    in div (created by TransitionGroup)
    in TransitionGroup (created by DialogInline)
    in div (created by DialogInline)
    in DialogInline

I tried setting default value to an empty array and the error disappeared. However, the dropdown is not loading at all now. How do I fix it?

Why do you specifically need it as an array if multiple prop is set?

I'm posting one of the Field with a custom component that I'm currently using.

      <Field
        name="recipients"
        value={normalizeMultipleSelectValues} // here I pass empty array if value is null/undefined
        component={AccountHolderSelectFormField}
        floatingLabel="Mail To:"
        fullWidth
        multiple
        withResetSelectAllButtons
      />
@saranshbansal saranshbansal changed the title Usage with redux forms Usage with redux forms: Value error on multiple selection Oct 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant