Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. const handleItemDelete = (index) => {
  2. console.log(index) //<==== why is index is a class?
  3. dispatch({
  4. type: "DELETE_ITEM",
  5. itemId: index,
  6. });
  7. };
  8.  
  9. <ul>
  10. {items.map((item, index) => (
  11. <li key={index.toString()}>
  12. {item}{" "}
  13. <button
  14. onClick={handleItemDelete}
  15. >
  16. X
  17. </button>
  18. </li>
  19. ))}
  20. </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement