I have some issues while calling save button in parent class to call method save in child class. I need to find a solution to call save function from parent component
class Parent extends React.Component{
render(){
return(
<Child />
<button onClick={Child.alert()}>save</button>
**// this button should call alert function now.**
)
}
}
export default Parent
// child component
class Child extends React.Component{
alert= () => {
console.log('child's alert called')
}
render(){
return(
<button onClick={this.alert()}>Save</button>
**// this is calling alert right now**
)
}
}
export default Child
**//when save button of the parent class called, it should call the alert
method in the child class.**