I'm trying to create FieldArray. I got sth like this:
<form>
<FieldArray
name="styles"
component={this.renderStyles}
/>
</form>
and then:
renderStyles = (props) => {
return(
<ul>
{props.fields.map((style, index) =>{
console.log(style)
return(
<li key={style} className="field-item">
<label>{style}</label>
<Field
name={`${style}`}
component="input"
type="checkbox"
/>
</li>)
}
)}
</ul>
)}
I also do initialize the values for FieldArray like this:
initialValues:{styles:[{style:'somestyle', img:'someimgurl'}]}
However the console.log(style) in renderStyles showes me only styles[0] as a string. No way to obtain the object. I tried different ways. HELP DERP! Please :)
props.fields.getAll().map...does the trick finally... Isn't it a bug in FieldArray though?