Below is my code in React Hooks:
I have three React functional components Parent, Child1, Child2. I want to click a button in Child2 component and that should invoke a function in Parent component. How this can be achieved ?
function Child2({Open, close, events, onEvent}) {
const passEventToParent = () {
// callback to parent using onEvent
}
<Button onClick={passEventToParent}>
}
function Child1({open, close, events, onEvent}) {
<Child2 />
}
function Parent({open, close, events, onEvent}) {
// I want call below function based on the button clicked in Child2 React functional component
runEvent();
<Child1 />
}