I'm trying to delete elements of array using splice of incoming index.
handleClick(index) {
const array = ['el1', 'el2', 'el3', 'el4'];
array.splice(index, 1);
this.setState({ data: array });
}
It works just fine but the result is that every time I fire handleClick in order to delete multiple elements I'm starting from the same point of const array. What I need to do is somehow save the array first without one element and when another handleClick is fired it'll work on smaller array, i.e. containing only three elements and making only 2 elements etc. How can I achieve that? Thank you