title: Understanding React's setState method
body: <p>I understand the below code adds a new object to an array of objects but fuzzy on a specific syntax:  <code>setProductList([array, obj])</code></p>
  <p>From what I'm seeing, the <code>setProductList</code> function takes in an object. That object consists of an array and an object. So how does it add the object to the array? is this built into JS or React?</p>
  <pre><code>// array of products
  const Products = [
    {
      item: &quot;basketball&quot;,
      price: 3,
      description: &quot;basketball desc&quot;,
    },
    {
      item: &quot;football&quot;,
      price: 5,
      description: &quot;football desc&quot;,
    },
  ];
  
  // setting state
  const [productList, setProductList] = useState(Products);
  
  // handling click
  const handleClick = () =&gt; {
     // Don't quite understand the syntax of below block
     setProductList([
        ...productList, // spread creates a copy of the array
        {
          item: &quot;baseball&quot;,
          price: 4,
          description: &quot;baseball desc&quot;,
        },
      ]);
    };
  
  </code></pre>