question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No way to show FieldArray validation errors for user if FieldArray has no items inside

See original GitHub issue

Release v6.5.0 introduces bugfix:

Do not set FieldArray as touched on submit.

Related links #2473 #2014

Here is meta props passed to my component (wrapped with FieldArray) initially:

{
	dirty: false,
	error: "Array should not be empty",
	invalid: true,
	pristine: true,
	submitting: undefined,
	touched: false,
	valid: false,
	warning: undefined
}

After user hit “Submit” button, component doesn’t rerenders and those props doesn’t changed. Now it’s impossible to show error to user if there is no items inside array - previously it was like this: (!pristine || touched) && invalid && error. Now this always false until user did not interact with component wrapped in FieldArray.

Example of this can be found in redux-form v6.5.0 FieldArray example - just hit “Submit” and you will not see errors regarding to members.

Possibly related issue: #2207

Is there any way to show errors to user until he interact with this component?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
jrgttcommented, Mar 13, 2017

Removing the touched property might solve some bugs, but introduces a new one. As in this example where you’ll never see the "At least one member must be entered" message.

I came here because I had the following problem: I have a radiogroup wrapped in FieldArray where one of the values of the group have to be selected by the user. Since the touched property was removed I can’t point to the user that the at least one of those radio buttons must be chosen.

My “solution” was to regress to 6.4.3 where this still works, but I hope this might be solved in future releases.

0reactions
lock[bot]commented, Dec 7, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

can't bind Formik Validations Errors for an array of object
I was facing a similar issue but I solved it using getIn . You can use it by following: import { getIn }...
Read more >
React FieldArray Form Tutorial: Using Formik, Yup ... - YouTube
In this tutorial, we'll build a donations platform using the Formik FieldArray form with React and Yup for validation.In order to validate ......
Read more >
<FieldArray /> | Formik
<FieldArray /> is a component that helps with common array/list manipulations. ... Determines if form validation should or should not be run after...
Read more >
FieldArray
Fields representing arrays have an additional layer of complexity, since array items may be reordered, added, or removed as well as updated. <FieldArray>...
Read more >
FieldArray - Redux Form
The FieldArray component is how you render an array of fields. ... if the array is invalid, it should return an error (usually,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found