Im trying to accomplish the same as what is explained on this SO question but in ReactJS. Which is calling a function that belongs to the parent from the page contained in the iframe, passing also parameters from the child to the parent.
So far I have in the parent page:
handleClickOnParent(someParams){
alert("My son clicked!"+someParams);
}
In the page contained in the iframe, the following:
handleClick(){
window.parent.handleClickOnParent(localParameters)
}
render(){
return(
<button onClick = {() => { this.handleClick() }}>Click me</button>
);
}
From which I get:
Uncaught TypeError: window.parent.handleClickOnParent is not a function
How can I call a function that is only available on the parent. I also tried passing the function as a prop, but it's not accesible from the iframe page, because it's not a component, it's a frame.