can’t retrieve data from the child component react

In the parent, you don’t need to write it as a callback. You can just do

changeComletedStatus = {this.changeComletedStatus}

The way you had it would need to be changeComletedStatus = {() => this.changeComletedStatus()} to actually call the function, but its not necessary as you’re not passing any arguments.

In the child, use the callback syntax and call your function with the id:

<button onClick = {() => props.changeComletedStatus(id)}>X</button>

Also, your changeComletedStatus is expecting an object with an id property on it…but you’re just passing it an id. Redefine the arguments for changeComletedStatus like so:

  changeComletedStatus = id => {

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top