Currently when the delete button is clicked it only deletes one row at a time. However, my current aim is for it do delete all rows at the same time but I the solutions I have tried do not work. Here is the current code:
const [shop, setShop] = useState([]);
...
const [count, setCount] = useState(0);
...
const handleDelete = (shopsId) => {
const newArr = [...shop];
const index = shop.findIndex((shop) => shop.id === shopsId);
newArr.splice(index, 1);
setShop(newArr);
setCount(count - count)
}
This method is successful if I want to remove a specific row however I do not want to do this but instead remove all the rows ('delete all'). Any help would be appreciated.
CodePudding user response:
set it as empty array
setShop([ ])