title: Best way to update object based on given ID
body: <p>I'm working on my first React personal mini project. Please go easy on me..</p>
  
  <p>In the past hour, i've been trying to source for the best way to update an item in an array based on a given ID. I found that this way seems to be the one people are using (using <code>findIndex</code>). I might not have searched deep enough was wondering if anyone could point out or improve on it?</p>
  
  <p>I've seen other methods too but i'm not too sure if it's the <strong>best way</strong>, though many ways.</p>
  
  <p>Here i've my state</p>
  
  <pre><code>state = {
      cards: [],
      updateId: ''
  };
  </code></pre>
  
  <p>This is how i updated it in a method handler</p>
  
  <pre><code>submit = e =&gt; {
      e.preventDefault();
      if (!this.state.formAddState) {
        const editCard = {
          reason: this.state.reason,
          description: this.state.description
        };
        let newCards = [...this.state.cards];
        let indexUpdate = newCards.findIndex(
          card =&gt; card.id === this.state.updateId
        );
        newCards[indexUpdate].reason = editCard.reason;
        newCards[indexUpdate].description = editCard.description;
        this.setState({
          cards: newCards
        });
        return;
      }
  };
  </code></pre>
  
  <p>Could be a duplicate.. Ultimately, i'd like to learn!</p>
  
  <p>Thank you!</p>