I've got a nested field arrays setup use react-hook-form
here. Take note that my actual code is a bit more complex, but the issue is displayed here just the same.
The issue I have is that if I delete an item in the list, say, ID: 2
in list [{ID:1}, {ID:2}, {ID:3}]
, the result isn't [{ID:1}, {ID:3}]
, but instead, [{ID:1}, {ID:2}]
.
Here's the official example, which gets nested fields array right.
Near as I can tell, the only difference is that my form relies on data that is retrieved from an API (in my example, handled by an async
function) whereas the official example uses data that's already been initiated.
Looking at samples online, some make use of the <Controller>
field, but that just gave me more issues (in my actual code), and upon testing (in Code Sandbox), doesn't really change the fact that deleting 2 doesn't shift the entire array up.
Is there anything I'm missing?