final-form/react-final-form-arrays

Conditionally-rendered FieldArray does not render children if fields.push() is called on initialise

jvke opened this issue · 4 comments

jvke commented

Are you submitting a bug report or a feature request?

Bug report

What is the current behavior?

Conditionally-rendered FieldArrays do not re-render when fields.push() is called manually.

https://codesandbox.io/s/react-final-form-field-arrays-28hnd/

What is the expected behavior?

fields.push() should result in fields prop changing, and a re-render occurring.

Sandbox Link

Type in the Company field to render the FieldArray. Delete what you typed, and type something again, and it will work as it should.
https://codesandbox.io/s/react-final-form-field-arrays-28hnd/

What's your environment?

Final Form 4.18.6
Final Form Arrays 3.0.2
React Final Form 6.3.3
React Final Form Arrays 3.1.1

Has anyone figured out a workaround for this issue?

This issue exist already a whole year and still there is no fix for that?

I really do not want to go back to redux-form where FieldArray works fine =(

Has anyone figured out a workaround for this issue?

The only way right now to fix it is to call fields.push() in setTimeout but that is dirty hack.