title: What is the best way to update an object in a usestate and see the change immediately
body: <pre><code>const TestScreen = (props) =&gt; {
  
      const [data, setData] = useState([ 
              { &quot;id&quot;: &quot;0&quot;, &quot;user&quot;: &quot;Lisa&quot;,&quot;amount&quot;: 1 },
          ]);
  
          return(
              &lt;View style={{
                              flex:1, 
                              alignItems:'center',
                              justifyContent:'center'
                          }}&gt;
              &lt;Text&gt;amount : {data[0].amount}&lt;/Text&gt;
              &lt;Text&gt;User : {data[0].user}&lt;/Text&gt;
              &lt;Button title=&quot;update&quot; onPress={()=&gt;setData(??????)}&gt;&lt;/Button&gt;
            &lt;/View&gt;
             
          )
      }
    
    export default TestScreen;
  </code></pre>
  <p>what is the best way to add an amount number on the user Lisa? i can do
  // setData([{ &quot;id&quot;: &quot;0&quot;, &quot;user&quot;: &quot;Lisa&quot;,&quot;amount&quot;: data[0].amount + 1}])
  but what i have 5 users or 20?</p>
  <p>even with a returning function nothing gets updated exept console logged witch show me the actual value</p>
  <pre><code>   let countAddFunc =(getArr)=&gt;{
            let arr = getArr
            arr[0].amount++
            console.log(arr[0].amount);
            return(
              arr
            )
          }
  
  &lt;Button title=&quot;update&quot; onPress={()=&gt;setData(countAddFunc(data))}&gt;&lt;/Button&gt;
  </code></pre>