react-hook-form: issue with clear array errors in FieldArray
When “errors” is empty the array is not been removed in “errors” object
Steps to reproduce the behavior:
- remove value from the first input
- submit button should be disabled
- enter “10” to the first input
- submit button still disabled
- look at
console.log(errors);. We still have an array in “errors” object
Expected behavior submit button should be active
Codesandbox link https://codesandbox.io/embed/react-hook-validate-trigger-sb1lj?fontsize=14&hidenavigation=1&theme=dark
discussion on spectrum https://spectrum.chat/react-hook-form/help/strange-validation-behavior-for-fields-array~b6982a9b-25f3-4fc7-adf5-cd3e1f5a27f7
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (10 by maintainers)
Commits related to this issue
- fix #1097 with unset issue around array errors — committed to react-hook-form/react-hook-form by bluebill1049 4 years ago
- close #1097 issue with formState — committed to react-hook-form/react-hook-form by bluebill1049 4 years ago
- 🐞 close #1097 issue with useFieldArray formState (#1111) * close #1097 issue with formState * fix type * fix delete index issue * revert logic * working version with formstate * opti... — committed to react-hook-form/react-hook-form by bluebill1049 4 years ago
sorted 😃 https://codesandbox.io/s/formstate-is-not-still-valid-after-removing-items-ewufu thanks a lot for your testing effort.
I didn’t find anything else.
Oh, look at this case:
IsValidis falseBut if you replace 5 and 6 steps, like 5. Click on Delete for the THIRD item 6. Click on Delete for the second item all looks good
Awesome thanks a lot, I will patch that issue tonight. ❤️
@bluebill1049 look at this example https://codesandbox.io/s/formstate-is-not-still-valid-after-removing-items-ycu19
Result
formState.isValidis still false.errorsobject containstest: [undefined]hey @DisaPadla you can install this beta on the CSB (ignore the drop down, just click install) 😃 make sure point to ‘react-hook-form’ instead of ‘./src’ folder.