If I have a react component that had a property set on it\'s state:
onClick() {
this.setState({ foo: \'bar\' });
}
Is it possible to re
If the removal is in a function and the key needs to be a variable, try this :
removekey = (keyname) => {
let newState = this.state;
delete newState[keyname];
this.setState(newState)
// do not wrap the newState in additional curly braces
}
this.removekey('thekey');
Almost the same as steve's answer, but in a function.