You want to update a quantity for a particular product but you're updating listData object, to fix this
First you need to pass some identifier to onChangeProductData if there is id on each product you can pass that or pass index
<select class="form-control " name="quantity" onChange={(ev) => onChangeProductData(ev, i)} value={current.quantity} > // here you can pass some id as well instead of index
Now
const onChangeProductData = (e, i) => {
const list = [...listData];
list[i] = {
...list[i],
[e.target.name]: e.target.value
}
setListData({
...listData,
list
})
}
Above changes will fix your problem:
Suggestion:
listData sould be like -
const [listData, setListData] = useState([]);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…