I have two sections side by side in a page, left section has an array list, what i want to do is, on click of li i want to delete it form left, and want to display on the right side. Iam not getting how to push it to right and delete from left.
displayLeftSide = () => {
let list = this.state.leftItems.map((lists, i) => {
return <li onClick={()=> this.deleteLeftItem(lists.key)} key={i}>
{lists}</li> ;
});
return list;
}
deleteLeftItem(index) {
let arr = [...this.state.leftItems];
let array = [...this.state.rightItems];
array.push(index, 1);
arr.splice(index, 1);
this.setState({rightItems: array});
this.setState({leftItems: arr});
console.log(arr)
console.log(array)
}