I got the property from the child but how can I pass to the parent?
in parent.js
<Child childId={() => this.getchildId()} />
getchildId = (id) => {
// do something
console.log(id) // return undefined
}
in child.js
const id = "something";
<Item itemid={this.getId(id)} />
getId = (id) => {
console.log(id); // return "something"
this.props.childId(id)
}
Update! It works with
in parent.js
<Child childId={this.getchildId} />
Now the problem is they are keep being called...