I want to sum the values of item.${index}.total_price to get totalAll. But I realized setFieldValue has a delay.
For example:
1st sum:
total_price: 3.00
total_all: 0
2nd sum:
total_price: 9.00
total_all: 3.00
what I want:
1st sum:
total_price: 3.00
total_all: 3.00
2nd sum:
total_price: 9.00
total_all: 9.00
Before this I've used useState to store the total_price values, but it also has a delay and it cannot dynamically change the total_price if there is changes in an index.
So how should I sum the total_price?