jquense / react-formal

Sophisticated HTML form management for React
http://jquense.github.io/react-formal
MIT License
526 stars 52 forks source link

FieldArray doesn't update children when new value is provided #177

Open stefvanhouten opened 3 years ago

stefvanhouten commented 3 years ago

I am trying to use the fieldarray as descirbed in http://jquense.github.io/react-formal/api/FieldArray. The only difference is that instead of using defaultValue I am using value hooked to the state to create a controlled component.

The issue occurs when the state changes, for example a new object gets pushed into the list, in this chase the arrayField is not updated and still shows the old values.

jquense commented 3 years ago

How are you pushing into the list? The array value isn't observed you need to use the array helper methods to do manipulations that RF knows about.

stefvanhouten commented 3 years ago

I tried using the array helpers but I need a dynamic field that is based on data coming from the server. I tried pushing/removing changed state with the arrayhelpers but when doing so I would get a warning that you cannot update a component while rendering.

jquense commented 3 years ago

There isn't much I can do to help without some code, can you reproduce the issue in a codesandbox?