react-hook-form: Uncaught TypeError: Cannot delete property '3' of [object Array]
I’m getting an error Uncaught TypeError: Cannot delete property '3' of [object Array].
My component is a dynamic that uses useFieldArray({ name: 'step.answers', control }).
if (defaultValues && fields.length < defaultValues.length) {
defaultValues.pop(); // here where it breaks
set(fieldArrayDefaultValuesRef.current, name, defaultValues);
}
defaultValues.length is 4, fields.length is 2. That’s why defaultValues.pop(); is fired.
Could you clarify please, why this error might happen? I can debug further then.
It would be nice to have a clarification error in the console for such cases.
I’d be glad to create a codesandbox, but my form is very complicated. With funnel and little-state-machine.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (8 by maintainers)
Commits related to this issue
- fix #3850 change method from pop to slice — committed to react-hook-form/react-hook-form by bluebill1049 3 years ago
Keep this open, i will patch this tonight and close it.
actually will do a slice and it would solve this issue for now.