import React from 'react'

const MultipleChoiceField = ({
  inputComponent: InputComponent,
  input,
  options,
  separator
}) => {
  
  let values = input.value ? input.value.split(separator) : []
  
  const onChangeField = (evt) => {
    const value = evt.target.value
    if (values.indexOf(value) !== -1) {
      values = values.filter(val => val !== value)
    } else {
      values.push(value)
    }
    input.onChange(values.join(separator))
  }

  return (
    <React.Fragment>
      {options.map((field) => (
        <InputComponent
          key={`inputKey-${field.value}`}
          {...field}
          checked={values.indexOf(field.value) !== -1}
          onChange={onChangeField}
        />
      ))}
    </React.Fragment>
  )
}

MultipleChoiceField.defaultProps = {
  separator: ';'
}

export default MultipleChoiceField

@@ -285,27 +285,21 @@
 s.in
-dexOf
+cludes
 (value)
- !== -1
 ) %7B%0A
@@ -440,17 +440,19 @@
 r))%0A  %7D%0A
+  
 %0A
-
   return
@@ -626,13 +626,14 @@
 s.in
-dexOf
+cludes
 (fie
@@ -645,15 +645,8 @@
 lue)
- !== -1
 %7D%0A  

change indexOf to includes on MultipleChoiceField