title: How to update the nested array using useState Hook in React
body: <p><strong>I am getting the error [The type cast expression is expected to be wrapped with parenthesis]</strong>
  <strong>Don't know how to update the nested array in useState.</strong></p>
  <pre><code>let tempArray = [
    {
      filterType: &quot;Company&quot;,
      dataList: []
    },
    {
      filterType: &quot;Vehicle&quot;,
      dataList: [&quot;Car&quot;, &quot;Bike&quot;]
    }
  ]
  
  const [resultList, setResultList] = useState(tempArray)
  const [indexChange, setIndexChange] = useState(0)
  
  // Assume here I am using fetch request and getting the response.
  if (responseJson.success) {
    setResultList(
      [
        ...resultList, 
        resultList[indexChange].dataList: responseJson.data
      ]
    )
  }
  </code></pre>
  <p><strong>Here I am rendering my result array. When clicking on the list! Based on the index, changes reflect.</strong></p>
  <pre><code>&lt;div className='filterTypeContainer' style={{ backgroundColor: &quot;#F5F6F8&quot;, padding: &quot;20px 20px&quot;, fontSize: 14, width: &quot;40%&quot; }}&gt;
    { resultList.map((list, index) =&gt; { 
    return &lt;div className='filerType' onClick={()=&gt; setIndexChange(index)}&gt;
      &lt;p&gt;{list.filterType}&lt;/p&gt;
    &lt;/div&gt;
    }) }
  &lt;/div&gt;
  </code></pre>