I am trying to find the best way to remove an element from an array in the state of a component. Since I should not modify the this.state variable directly, is
removeFunction(key){
const data = {...this.state.data}; //Duplicate state.
delete data[key]; //remove Item form stateCopy.
this.setState({data}); //Set state as the modify one.
}