Let's say I have the following react code.
<Navigation parentWindow={this} />
<p>Sub Pages</p>
<ReactCSSTransitionGroup
component="div"
transitionName="page-transition"
transitionEnterTimeout={0}
transitionLeaveTimeout={500}
>
{React.cloneElement(this.props.children, {
key: location.pathname
})}
</ReactCSSTransitionGroup>
The ReactCSSTransitionGroup will eventually render a <ContactPage /> which is created by a ContactPage.js. Here's what ContactPage.js looks like:
import React from 'react';
export default class Page extends React.Component
{
testMe() {alert('Hello World!');}
render() {return <div>Hello</div>;}
}
From my <Navigation /> which is created by Navigation.js, I want to be able to trigger the ContactPage.testMe(). So I did this in my Navigation.js
import React from 'react';
export default class Page extends React.Component
{
render() {
this.props.parentWindow.props.children.testMe();
return <div>Navigate me</div>;
}
}
But when I run the project, my Navigation gives me the error:
Uncaught TypeError: this.props.parentWindow.props.children.testCall
How do I get around this problem?
export default class Page extends React.Componentin your Navigation.js. Is that just a copy and paste mistake?