Search code examples
redux-form

Edit Redux Form with FieldArray


I have create a Redux Form with FieldArray as mentioned in its example, where you can add multiple Member and Hobbies and Submit the Form.

https://redux-form.com/8.1.0/examples/fieldarrays/

Can we Edit the same Form by accessing the form from database? The Edit form should display all the fields and Button I have created before ?

Please advise how different sub-component(which is created using FieldArray ) will populate the values.

Thank you


Solution

  • You can reuse the same form for editing.

    A field array is mapped into redux as array of objects or array of strings (depending how you do the fields.push).

    If you provide that exact format to the initialValues prop when you mount the redux form, it will populate the FieldArray accordingly