You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose contactPersons is an array of objects consisting of id of type Long as one of the attributes, id is generated from database and default value of contactPersons is retrieved from api call to a spring boot backend server. Since useFieldArray automatically generates a unique id of type string which is used for key prop, is it possible to use the id generated from database for key prop and instead of using the built-in field.id?
I did some research and find that I can add keyName: "reactHookFormId" as prop in useFieldArray so that the automatically-generated id will be assigned to custom keyNamereactHookFormId instead of overriding the Long value of id in the object. However, react-hook-form documentation states that "This prop is no longer required and will be removed in the next major version.". Thus this approach can't be used.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Suppose
contactPersons
is an array of objects consisting ofid
of typeLong
as one of the attributes,id
is generated from database and default value ofcontactPersons
is retrieved from api call to a spring boot backend server. SinceuseFieldArray
automatically generates a uniqueid
of typestring
which is used for key prop, is it possible to use the id generated from database for key prop and instead of using the built-in field.id?I did some research and find that I can add
keyName: "reactHookFormId"
as prop inuseFieldArray
so that the automatically-generated id will be assigned to customkeyName
reactHookFormId
instead of overriding the Long value of id in the object. However, react-hook-form documentation states that "This prop is no longer required and will be removed in the next major version.". Thus this approach can't be used.Beta Was this translation helpful? Give feedback.
All reactions