title: Spread operator to update array of objects
body: <p>I have an array of objects. In that array, I want to update a single object, and in that object, I want to update only specific properties. I tried:</p>
  <pre><code>setRequiredFields(prevRequiredFields =&gt; ([
              ...prevRequiredFields, prevRequiredFields.find(x =&gt; x.name = field) ?  {
                  isValid: isValid,
                  content: content,
                  isUnchanged: false
              }
  ]));
  </code></pre>
  <p>But it didn't work. Required fileds is an array with the following structure:</p>
  <pre><code>[{
      name: &quot;Name&quot;,
      isValid: false,
      content: &quot;&quot;,
      isUnchanged: true,
      tip: &quot;Name cannot be empty&quot;,
      isValidCondition: notEmptyRegex,
      reportState: validateField
  }]
  </code></pre>
  <p>What I'm trying to do here is to update only a <code>isValid</code>, <code>content</code> and <code>isUnchanged</code> of one specific object inside that array. How can I accomplish that?</p>