final-form / react-final-form-arrays

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

Cannot read property 'validators' of undefined" in final-form when change version of final-form-arrays #158

Open 2u4u opened 3 years ago

2u4u commented 3 years ago

Are you submitting a bug report or a feature request?

Bug report

What is the current behavior?

Changing version of final-form-arrays in simple example causes error "Cannot read property 'validators' of undefined" in final-form. Steps to reproduce:

  1. Open simple example from docs
  2. Change version of final-form-arrays
    - "final-form-arrays": "1.1.2", + "final-form-arrays": "^1.1.2",
  3. Add customer in the list
  4. Remove customer from the list with click on ❌

What is the expected behavior?

Project works properly

Sandbox Link

Simple example with changed final-form-arrays version

ewedlund commented 3 years ago

Not sure if this is helpful:

I stumbled on this while having issues with react-final-form-html5-validation

In a FieldArray with field validation, if I remove any object except the last one, the validation seem to use the old object's data. E.g. I add two objects, then remove the first one, even if I insert valid data, the validation fails on exactly those fields that were not filled in for the removed object.

I was unable to create a sandbox to describe the problem because of the issue described by @2u4u, but downgrading to final-form-arrays 1.1.2, the issue with react-final-form-html5-validation went away in my project, so I suppose it is a problem in this library and not react-final-form-html5-validation.

FWIW here's the sandbox, but downgrading the library, it now works as expected: FieldArray with html5 validation