I want to access the DOM node of a child component defined in a parent component. In the sample below I've tried both the "try1" and "try2" methods and neither works. How do I get the DOM node for the "theDiv" ref?
<Form>
<Frame>
<div ref="thediv" />
</Frame>
</Form>
Form.render() {
return (
<Frame>
<div ref="theDiv" />
</Frame>
}
try1.Frame.componentDidMount() {
let theDiv = ReactDOM.findDOMNode(this.refs.theDiv);
}
try2.Frame.componentDidMount() {
React.Children.forEach(this.props.children, child => {
if (child.ref === "theDiv") {
let theDiv = ReactDOM.findDOMNode(child);
}
});
}