final-form / react-final-form-arrays

A component for rendering and editing arrays 🏁 React Final Form
MIT License
204 stars 69 forks source link

"Array mutators not found. You need to provide the mutators from final-form-arrays to your form" is thrown although array mutators are passed #136

Open aquinq opened 4 years ago

aquinq commented 4 years ago

Are you submitting a bug report or a feature request?

Bug report

What is the current behavior?

I have two routes, each containing a single Form (nothing more). The first Form has no mutators, just an input Field. The second Form is passed arrayMutators to mutators prop for its FieldArray.

When navigating from the first to the second route,

Array mutators not found. You need to provide the mutators from final-form-arrays to your form

is thrown, although the second form is passed arrayMutators.

What is the expected behavior?

The second form renders normally.

What seems to happen

It seems the second form is rendered using the first form ref, returned by useConstant (here) (which is probably the root cause of this issue). Then, useWhenValueChanges is called with mutators (here), which will set the second form mutators config later using a side effect (here). The thing is, when hasMutators boolean is defined (here) the side effect has not run yet.

Sandbox Link

https://codesandbox.io/s/eager-sinoussi-405f2

What's your environment?

React Final Form Arrays 3.1.1

aquinq commented 4 years ago

A workaround is to set a unique key prop to each Form, to make sure the ref used by react-final-form will not be reused to render the other Form.

mauron85 commented 1 year ago

Still an issue