title: React - Updating state (array of objects). Do I need to deep copy the array?
body: <p>I have the following <code>state</code>:</p>
  
  <pre><code>const[images,setImages] = useState([
    {src: 'stringSRC1', selected: false},
    {src: 'stringSRC2', selected: false},
    {src: 'stringSRC3', selected: false}
  ]);
  </code></pre>
  
  <p>I'm updating it (toggling selected state) with this code:</p>
  
  <pre><code>function handleImageClick(index) {
    props.setImages((prevState)=&gt;{
      const aux = Array.from(prevState);
      aux[index].selected = !aux[index].selected;
      return aux;
    });
  }
  </code></pre>
  
  <p>It works as intended. But I've thought of one thing.</p>
  
  <p>When I'm copying the array from <code>prevState</code>, <strong>I'm creating a new array, but the objects (stored as references) will remain the same.</strong> I've tested and they do not change when you copy the array like that.</p>
  
  <p><strong>QUESTION</strong></p>
  
  <p>Is this a bad practice? Should I bother to deep copy the array, as in create a new array and create brand new objects? Or this is just fine?</p>