redux-form: FieldArray broken in v 8.2

Are you submitting a bug report or a feature request?

bug report

What is the current behavior?

Pushing a new field into a field array is broken

  1. Visit https://redux-form.com/8.2.0/examples/fieldarrays/
  2. Click “Add Member”
  3. See TypeError: Invalid attempt to spread non-iterable instance in console

What is the expected behavior?

A new member field should be pushed into the field array

Sandbox Link

https://codesandbox.io/s/nrzq9mzp34 https://nrzq9mzp34.codesandbox.io/

What’s your environment?

Redux-form v8.2 (not 8.1) At least Chrome 73, Safari 12.1, Firefox 65

Other information

Screen Shot 2019-04-15 at 10 51 50 PM

Recent potentially related commit https://github.com/erikras/redux-form/commit/fc3b48d0557c4bd0dac27cc5f6c22d984fdf1860 I say potentially as I see it was added in 8.2 and has the word FieldArray in it. Haven’t wrapped my head around it all

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 16
  • Comments: 21 (8 by maintainers)

Commits related to this issue

Most upvoted comments

This is a major issue and I can confirm that it’s not working 8.0.0 onwards. Must be something more fundamental due to v8 change.

Published fix in v8.2.1.

Experiencing the same error on 8.1.

@nikhilag I have a simple codesandbox working on 8.1

https://codesandbox.io/s/30xx4588lm

Fairly certain was something with the commit I referenced above

The issue is that if you revert the PR then it will break redux-form ImmutableJS compatibility. I’m sorry for the trouble my PR #4337 caused everyone! It seems that some lower level functionality needs to be rewritten in the library to support both Immutable and non-Immutable usage. The issue with enabling loose mode is that now the immutable lists will be assumed to be arrays. This will break a number of functions when used with Immutable. There should be a warning for users of redux-form and ImmutableJS not to update to v8.2.1 or it will break their project. Also I suggest that v8.2.1 tag should be removed and the next release version should be v9.0.0 since this is a breaking change for ImmutableJS users. If ImmutableJS support is officially being dropped then that should be noted that v8.2.0 is the last version with support.

@renatoagds Great news thanks! I hadn’t forked it quite yet. I would recommend that the new version includes a release for the docs so that the Field Array example works again!

Hi all! Made the revert of the PR that caused this problem. Will release a new version in the next few hours. 😃

Today I have to validate if one FieldArray has elements, using this (as the documentation says): if (!values.options || !values.options.length) { errors.options = { _error: 'You have to provide at least one option.' }; }

With that on the validator, I receive this error: Uncaught TypeError: Invalid attempt to spread non-iterable instance I note that if I remove that condition on the validator, everything works well, so maybe that’s a start to detect where is the bug or at least get a workaround. For now, I have to go back to 8.1.0.