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 &&, index) => {
            return (
{, indexs) => {
            return (
                <td>{indexs + 1}</td>
                  <div key={indexs}>
                    <input className="w-full bg-gray-100" type="number" value={productQuantity[indexs]} required={true} onChange={updateFieldChanged(indexs)} />
const updateFieldChanged = index => e => {
  let newArr = [...productQuantity]; 
  newArr[index] =; 

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