Hello, I have been having some trouble calling a child components method using refs as this example suggests: https://github.com/kriasoft/react-starter-kit/issues/909#issuecomment-252969542.
Here is how I implemented the example into my code:
import React, { Component } from 'react';
import Fractal from './Fractal.js';
import Share from './Share';
import Helmet from 'react-helmet';
// App component - represents the whole app
export default class App extends Component {
constructor(props) {
super(props);
this.appsenddown = this.appsenddown.bind(this);
}
appsenddown() {
this.refs.child.signalchild();
}
render() {
return (
<div className="container">
<Fractal onRef={ref => (this.child = ref)}/>
<Share triggerParentUpdate = {this.appsenddown}/>
</div>
);
}
}
The error message I get in my browser is:
TypeError: this.refs.child is undefined [App.js:14:2]