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: 
You can make use of setState callback and array destructuring to update your state

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

setUsers(([first, second, ...rest]) => [
  { ...first, order: 40 },
  { ...second, order: 12 },
  ...rest
]);

```
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**