nicolaslopezj/simple-react-form

How get index in Array type Field

rgnevashev opened this issue · 2 comments

<Field fieldName="sections" type={Array}>
   <Field fieldName="type" type={Select} />
   {this.state.sections[<how get index here?>].type === 'value' &&
       <Field fieldName="headline" type={Text}>
   }
</Field>
class Payments extends React.Component {

  renderItem (item, index) {
    return (
      <div>
        <Field fieldName="type" type={Select} />
        {this.state.sections[index].type === 'value' &&
          <Field fieldName="headline" type={Text} />
        }
      </div>
    )
  }

  render () {
    return (
      <Form>
        <Field
        fieldName='sections'
        type={Array}
        renderItem={this.renderItem.bind(this)} />
      </Form>
    )
  }
}

Thank you very much! cool a way)