I have an object array similar to below
[array1, setArray1] = useState(
[
{
name: "somename",
count: 0,
division: "somedivision",
cost: 1000,
},
{
name: "secondname",
count: 0,
division: "somedivision",
cost: 2000,
},
]
)
How can i individually update the cost value of each object in my list?
I was thinking of something like setArray1((previous) => ({...previous, cost: newcost}))
But how can i do this for multiple objects in an object array?