I have array of objects where i need to an key value
useState :
const [row, setRow] = useState([{ nameofthework: "", schedulerefNo: "", unitprice: "", qty: "", uom: "", gst: "", total: "" }]);
The form input change function
const handleInputChange = (e, index) => { const { name, value } = e.target; const list = [...row]; list[index][name] = value; setRow(list); console.log(row); // Prints out the each row object into and array of objects }; const handleQty = (e) => { const scheduleNumberForQuantity = e.target.value; projectScheduleNumber?.filter((v) => { if(v["Schedule No"] === scheduleNumberForQuantity ) { setScheduleQuantity(v["LOA Qty"]); // return only integer example 1000 } }) }
How to add handleQty value to row state ?
https://stackoverflow.com/questions/66847919/react-js-add-key-value-pair-to-existing-object March 29, 2021 at 10:04AM
没有评论:
发表评论