Using setValue right after another #11199
Unanswered
zju1
asked this question in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using
useFieldArray
and it's working normal. Every item of fieldArray has values below: quantity/cost/margin/price. So my array is like this:When
cost
change I have to calculate theprice
usingcost and margin
and set both values at the same time.And when
price
change I have to calculate themargin
using the price and the cost and set both values.And when the
margin
change I have to calculate the price using cost and margin and set both values.I'm doing something like this:
I have 3 functions like this.
And they're causing to invoke each other. But I want them to invoke when user changes the inputs. Setting the value of price on
handleCostChange
function invokinghandlePriceChange
function. So I need something likesetValues(index, partial values)
. I know that there'supdate
function. But it re-renders whole fieldArray item. I mustn't re-render.Is there any solution to
avoid using setValue
right after another?Beta Was this translation helpful? Give feedback.
All reactions