I am working on the react hook form with typescript. My data structure looks array within array. so I try to use the useFieldArray
allName: [
{
name: "useFieldArray1",
nestedArray: [
{ name1: "field1", name2: "field2" },
{ name1: "field3", name2: "field4" }
]
},
{
name: "useFieldArray2",
nestedArray: [{ name1: "field1", name2: "field2" }]
}
]
But when I try to set the name for the input like allName[${nestIndex}].nestedArray
I got the below warning.
Type 'string' is not assignable to type '"allName" | `allName.${number}.nestedArray`'
Here I have attached the code sandbox link of my code. https://codesandbox.io/s/gallant-buck-iyqoc?file=/src/nestedFieldArray.tsx:504-537 How to fix this issue?
from got error in Type 'string' is not assignable to type '"allName" | `allName.${number}.nestedArray`' in react hook form with typescript
No comments:
Post a Comment