Ok, what you're trying to achieve is to basically "toggle" items in the array, right?
I'd suggest you to try this:
In your dddd method (Awful name btw):
dddd = (selectedItem) => {
const { listofdata } = this.state;
const newList = [ ...listofdata ];
const itemIndex = newList.findIndex(item => item.name === selectedItem.name);
if (itemIndex > -1) {
newList.splice(itemIndex, 1);
} else {
newList.push(selectedItem);
}
this.setState({
listofdata: newList,
})
}
Hope it helps!