Question: I have a simple list of users

```
const [users, setUsers] = useState([
    { name: 'john', order: 0 },
    { name: 'mary', order: 1 },
    { name: 'Lou', order: 200 }
]);

```

I want to set order = 40 to the first element and order = 12 to the second element in the same operation

```
setUsers(...users, ?, ?)

```

Answer: 
Since React's state should be immutable, you would need to do deep cloning (either through a library such as **lodash**, or manually).

I recommend using [Immer](https://github.com/immerjs/immer) which not only makes things easier, but also is much more efficient than creating deep clones:

```js
import produce from "immer";

const [users, setUsers] = useState([
    { name: 'john', order: 0 },
    { name: 'mary', order: 1 },
    { name: 'Lou', order: 200 }
]);

setUsers(produce(users, draftUsers => {
    draftUsers[0].order = 12;
    draftUsers[1].order = 40;
});

```

Voilà, the beauty of this is that the object `Lou` remains unchanged, hence internally, `immer` won't recreate it.

Be careful to avoid *shallow* cloning:

```js
const newUsers = [...users];  // new copies of the user objects... right?

newUsers[0].order = 12 ;
console.log(users[0].order);  // -> 12 <-  oops! We mutated the state >_<

```
you can do it easily using the Index or add mew field 'ID' like here:
=====================================================================

use a filter to match index/id and then change your object item. link: [codesandbox.io](https://codesandbox.io/s/trusting-grass-4nnvv)

```
const [users, setUsers] = useState([
    { name: 'john', order: 0 },
    { name: 'mary', order: 1 },
    { name: 'Lou', order: 200 }
]);

const changeUserData = (index, amount) => {
  let _users = users.map((user, i) => {
    if(i===index) {
      user.order = 40
    }
    return user;
  })

  setUsers(_users);
} 

<ul style={{textAlign: 'left'}}>
    {
    users.map((user, index)=> (
      <li key={index}>Name: {user.name}, Order: {user.order}</li>
    ))
  }
</ul>

<button onClick={(e)=>changeUserData(0, 40)}>Click to update</button>

```

Maybe it helps to solve your problem,

**Thank you**