title: Removing object from array using hooks (useState)
body: <p>I have an array of objects. I need to add a function to remove an object from my array without using the "this" keyword.</p>
  
  <p>I tried using <code>updateList(list.slice(list.indexOf(e.target.name, 1)))</code>. This removes everything but the last item in the array and I'm not certain why.</p>
  
  <pre><code>const defaultList = [
  { name: "ItemOne" },
  { name: "ItemTwo" },
  { name: "ItemThree" }]
  
  const [list, updateList] = useState(defaultList);
  
  const handleRemoveItem = e =&gt; {
      updateList(list.slice(list.indexOf(e.target.name, 1)))
  }
  
  return (
      {list.map(item =&gt; {
          return ( 
              &lt;&gt;
              &lt;span onClick={handleRemoveItem}&gt;x &lt;/span&gt;
              &lt;span&gt;{item.name}&lt;/span&gt;
              &lt;/&gt;
          )}
      }
  
  )
  
  </code></pre>
  
  <p>EXPECTED: The clicked item will be removed from the list.<br/>
  ACTUAL: The entire list gets removed, minus the last item in the array.</p>
  
  <p>Thanks in advance for any input!</p>