I'm building a todo application in which all elements are inserted in a list of objects and then mapped using the map() function. I'm attempting to add a button with every map, that once clicked - will delete the specific element from the list. I've read quite a bit of documentation relating to the connection of useState and map(), but I'm still confused in how to implement this, and connect the specific element to the removal.
import { useState } from "react";
const List = (props) => {
return props.items.map((item) => {
return (
<>
<div>
<p>{item.item}</p>
<p>{item.date}</p>
<p>{item.id}</p>
</div>
{/* Below is the button im attempting to implement */}
<button onClick={}>Remove Item</button>
</>
);
});
};
export default List;