Last post Oct 24, 2019 10:49 PM by EnenDaveyBoy
Oct 24, 2019 02:02 AM|EnenDaveyBoy|LINK
i have a formik field array, in a form, its just an array of objects the object has a startDate, and endDate and an id
in the docs have a component call FieldArray which has props which are the arrayHelper methods and all is find
however thats where the docs information to field arrays ends, and here is my issue
how do i build a component which loops through the array? the fieldarray component doesn't have its own values,although you can access them via the form prop but that means the props will change on every element change, the field array doesn't allow me
to addmy own props (or at least when i look at the props it doesn't show in the console, the connect options has the same issue with using the form values.
i have it working at the moment using the form props values which i really don't like, and can't think of a good reason or way arround the field array no having its own values.
Any suggestions would be appriciated.
Oct 24, 2019 02:06 AM|EnenDaveyBoy|LINK
hmmm do i just use a normal field component for the array information?
although thats still messy as it means the arrayhelpers is seperate from the array fields, eg i want to use the remove inline with the form fields and the add outside, it would be simple if the fieldarray value was passed into the fieldarray component.
Oct 24, 2019 04:01 PM|bruce (sqlwork.com)|LINK
I fail to understand your question. The field array is to handle the common case where the form state contain an array of objects, and you want to render a common template for each item in the array. The array helper methods are just for adding, removing,
moving items items in the array, without having to write the update state management code.
to loop thru the array, it just part of the form objects, you don’t need the array handlers, just use the standard Array.map method.
Oct 24, 2019 10:49 PM|EnenDaveyBoy|LINK
after writing a long reply, i am a dumb ass, basically i wanted to put the whole div row in component, i can put put the fields i need,although i think its messy