title: React setState for dynamic array
body: <p>I'm using react hook  to setState using dynamic key like this.
  Final output should contains only unique key(no duplicate key)</p>
  <p>My code:</p>
  <pre><code>const [sub, setSub] = React.useState();
  
  setValue({
        [name]: { ...value, [key]: event.target.value }
  });
  </code></pre>
  <p>Output got as:</p>
  <pre><code>{
    &quot;0&quot;:&quot;P&quot;,&quot;1&quot;:&quot;r&quot;,&quot;2&quot;:&quot;o&quot;,&quot;3&quot;:&quot;d&quot;,&quot;4&quot;:&quot;u&quot;,&quot;5&quot;:&quot;c&quot;,&quot;6&quot;:&quot;t&quot;,&quot;7&quot;:&quot; &quot;,&quot;8&quot;:&quot;T&quot;,&quot;9&quot;:&quot;y&quot;,&quot;10&quot;:&quot;p&quot;,&quot;11&quot;:&quot;e&quot;,
    &quot;Assignee&quot;:&quot;Mike&quot;,&quot;Product Type&quot;:&quot;Product 2&quot;
  }
  </code></pre>
  <p>Expected output:</p>
  <pre><code>{
    &quot;Assignee&quot;:&quot;Mike&quot;,
    &quot;Product Type&quot;:&quot;Product 2&quot;
  }
  </code></pre>