Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

redux-form FieldArray modifies props

I am trying to find a lib to use for my forms, to handle validation and stuff, and I come across redux-form which seems to be the most popular one.

There is one thing that troubles me with it though. In FieldArray example https://redux-form.com/7.2.3/examples/fieldarrays/ they modify props to add/remove fields. Isn't that actually anti-pattern which conflicts with functional programming principles?

like image 409
jbojcic Avatar asked Apr 21 '26 01:04

jbojcic


1 Answers

From the docs: https://redux-form.com/7.3.0/docs/api/fieldarray.md/

fields.push(value:Any) : Function

Adds a value to the end of the array. Returns nothing.

This is not a mutator; it dispatches an action which updates the state in Redux, which will cause your component to rerender.

like image 66
Peter Riesz Avatar answered Apr 23 '26 14:04

Peter Riesz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!