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
I am still in learning stage of coding. I have 2 basic requirements that I cannot perform using useFieldArray.
My useFieldArray name is invoiceItems. And each of my fields will contain the following input fields - productName, productCode, unitPrice, quantity, lineTotal.
1st requirement - The value of lineTotal will be unitPrice*quantity. I do not know what is the correct way to do that. I have done similar thing using setValue inside an useffect and keeping the required input value (using watch ) as a dependency of that useEffect. But here I cannot access the value of unitPrice or quantity individually without mapping the whole array. And useEffect does not work inside map.
2nd requirement - I want the values of productcode and unitPrice to auto-populate following the value of productName. But outside the fields.map(), is there any way to know which field is currently taking input inside fields.map() ?
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.
Uh oh!
There was an error while loading. Please reload this page.
-
I am still in learning stage of coding. I have 2 basic requirements that I cannot perform using useFieldArray.
My useFieldArray name is invoiceItems. And each of my fields will contain the following input fields - productName, productCode, unitPrice, quantity, lineTotal.
1st requirement - The value of lineTotal will be unitPrice*quantity. I do not know what is the correct way to do that. I have done similar thing using setValue inside an useffect and keeping the required input value (using watch ) as a dependency of that useEffect. But here I cannot access the value of unitPrice or quantity individually without mapping the whole array. And useEffect does not work inside map.
2nd requirement - I want the values of productcode and unitPrice to auto-populate following the value of productName. But outside the fields.map(), is there any way to know which field is currently taking input inside fields.map() ?
Beta Was this translation helpful? Give feedback.
All reactions