const removeProduct = (index) => {
setProductsArray([
...products.slice(0, index),
...products.slice(index + 1, products.length)
]);
}
const defaultList = [
{ name: "ItemOne" },
{ name: "ItemTwo" },
{ name: "ItemThree" }
];
const [list, updateList] = useState(defaultList);
const handleRemoveItem = (e) => {
const name = e.target.getAttribute("name")
updateList(list.filter(item => item.name !== name));
};
let index = array.indexOf(e.target.value)
if (index !== -1) {
array.splice(index, 1);
setState(array);
}