onClick event not working when changing the parameter name

Viewed 37

enter image description here


So I have an event on Click . it works when i pass "id" as parameter but doesn't work when i pass "key" , even though all the properties of id and key are same(see the image). below is the method I have already made all the properties of ID and KEY same , but it seems not to work.


onClick={ () => this.props.onDelete(this.props.key)}

VS

onClick={ () => this.props.onDelete(this.props.id)}
2 Answers

key is a reserved prop in a React component. You won't be able to access it in child component. If you need it, give it some other name.

Related