issue: Cannot move item in fieldArray which has its own fieldArray #10812
-
Version Number7.43.9 Codesandbox/Expo snackhttps://codesandbox.io/s/heuristic-meadow-pkvtcd?file=/src/App.tsx Steps to reproduceIn the provided sandbox I've built a nested, dynamic form with three possible "things" you can add to the form:
The real form I work with has a lot more to it, but this is the minimum code required to reproduce the error, which occurs when re-arranging the items within the form. To reproduce the error:
Expected behaviourIn the sample app, the section should be moved above the standalone question. What browsers are you seeing the problem on?Firefox, Chrome, Edge Relevant log outputTypeError: Cannot set properties of undefined (setting 'mount')
t
https://pkvtcd.csb.app/node_modules/react-hook-form/dist/index.cjs.js:1:3990 Code of Conduct
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
react-hook-form v7 is targeting on field level handling while your field name is still using object data and it polluted the field array object (your Just use directly field name Working demo: https://codesandbox.io/s/naughty-christian-ltg39g?file=/src/App.tsx |
Beta Was this translation helpful? Give feedback.
@pyramid-scheme-ceo
react-hook-form v7 is targeting on field level handling while your field name is still using object data and it polluted the field array object (your
items.$index
will be overridden byitems.$index.questions.$index
.Just use directly field name
item.$index.name
anditem.$index.questions.$index.name
will solve the issue.Working demo: https://codesandbox.io/s/naughty-christian-ltg39g?file=/src/App.tsx