change value in array react 1

change value in array react

setOfficeSpace([...officeSpace, { ...item, number: 1, type: item.key }]);

Here is what the above code is Doing:
1. We’re using the spread operator to create a new array with the existing officeSpace array.
2. We’re adding the item object to the new array.
3. We’re adding a number property to the item object.
4. We’re adding a type property to the item object.

Similar Posts