title: How to update state of one object in array React Native using hooks
body: <p>I'd like to update a state of one object in array, not updating the state of whole array.</p>
  
  <pre><code>const [users, setUsers] = useState;
  
  const data = [
  { 
      id: 1,
      name: "John",
      activeAccount: 1 
  },
  { 
      id: 2,
      name: "Mary",
      activeAccount: 1 
  },
  { 
      id: 3,
      name: "Max",
      activeAccount: 1 
  }
  ]
  
  </code></pre>
  
  <p>For example, John deactivate his account and state of activeAccount should be updated to 0. 
  So only one object should be updated (he has no data from other users and cannot update all array) - just example, why i use here <code>user.id</code></p>
  
  <pre><code>
  const index = users.findIndex(obj =&gt; obj.id === user.id); // find index of object
  users[index].activeAccount = 0
  setUsers(users) // Nothing updated
  
  </code></pre>
  
  <p>I also tried to use <a href="http://ttps://reactjs.org/docs/update.html" rel="nofollow noreferrer">Immutability Helper</a> </p>
  
  <pre><code>import update from 'immutability-helper';
  
  const index = users.findIndex(obj =&gt; obj.id === user.id); // find index of object
  setUsers({
     users: update(...users, {index: {activeAccount: {$set: 0 }}})
  })
  
  </code></pre>
  
  <p>Could anyone help? Is there a solution?</p>