If I have something like
And I want to access from
/*
* Child component
*/
class Child extends React.Component {
render() {
return (
{ this.heading = node; }}>
Child
);
}
}
/*
* Parent component
*/
class Parent extends React.Component {
componentDidMount() {
// Access child component refs via parent component instance like this
console.log(this.child.heading.getDOMNode());
}
render() {
return (
{ this.child = node; }}
/>
);
}
}
Demo: https://codepen.io/itsfadnis/pen/aLWVVx?editors=0011