How can I loop through paragraphs in Child component and get its innerHTML value in Parent component? I have to do this with refs.
class Parent extends React.Component {
render() {
return (
<Child
textRef={el => this.textElement = el}
/>
);
}
}
function Child(props) {
return (
<div>
<p ref={props.textRef} >abc</p>
<p ref={props.textRef} >def</p>
<p ref={props.textRef} >ghi</p>
</div>
);
}