Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const handleItemDelete = (index) => {
- console.log(index) //<==== why is index is a class?
- dispatch({
- type: "DELETE_ITEM",
- itemId: index,
- });
- };
- <ul>
- {items.map((item, index) => (
- <li key={index.toString()}>
- {item}{" "}
- <button
- onClick={handleItemDelete}
- >
- X
- </button>
- </li>
- ))}
- </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement