0

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.

1 Answer 1

1

set it as empty array

setShop([ ])

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.