I am a React beginner. While learning React, sometimes I see people use anonymous functions in event listeners, I wonder if the below codes are the same. I think, to call function onDelete, we only need to use onClick={this.onDelete(id)}
const cartItem=this.props.cart.map((bookCart)=>{
return (
<Button onClick={()=>{this.onDelete(bookCart._id)}}>Delete</Button>
)
},this;
and
const cartItem=this.props.cart.map((bookCart)=>{
return (
<Button onClick={this.onDelete(bookCart._id)}>Delete</Button>
)
},this;