title: Best ways to update state array object using React Hooks?
body: <p>Actually I have a list of elements, that have to store into an array as react state.</p>
  <pre><code>const [data, setData] = useState([{&quot;name&quot;: &quot;joy&quot;, &quot;age&quot;: 25}, {&quot;name&quot;: &quot;tom&quot;, &quot;age&quot;: 41}]);
  </code></pre>
  <p>Somehow I need to update only a particular object, May be <strong>name</strong> or <strong>age</strong>.</p>
  <p>I am doing in such way. But It seems not good.</p>
  <pre><code>    setData(prevState =&gt; {
        let obj = prevState.find(o =&gt; anycondition);
        if(obj !== undefined) {
          obj.name = &quot;Demo&quot;;
        }
        return [...prevState];
      })
  </code></pre>
  <p>is there any other method to update only object from state array using React Hooks?</p>