Javascript update react state using index in 2nd for loop

I'm trying to update my state using index, I have 2 or more objects in my state when I try to update state which index[1], it change other object's index[1] as well. I want to update individually even they have a same index in different object. This is first loop. I want to display in selectedArray which is in 2nd loop and update productQuantity using index. prevent in confusion, when I update first index in 2nd Object, first index in first object also updated. that's the problem.

{preInvoice && preInvoice.map((item, index) => {
            return (
{item.selectedArray.map((items, indexs) => {
            return (
            <tbody>
              <tr>
                <td>{indexs + 1}</td>
                <td>
                  <p>{items?.productInfo?.productName}</p>
                </td>
                <td>
                  <div key={indexs}>
                    <input className="w-full bg-gray-100" type="number" value={productQuantity[indexs]} required={true} onChange={updateFieldChanged(indexs)} />
                  </div>
                </td>
const updateFieldChanged = index => e => {
  let newArr = [...productQuantity]; 
  newArr[index] = e.target.value; 

  setProductQuantity(newArr);
}
How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum