I have two components:
Parent.js
export default class Parent extends React.Component {
handleTagHierClick(e) {
var excel = this.refs.workbook;
excel.click();
}
render() {
return (
<button onClick={(e) => this.handleTagHierClick(e)} className="btn btn-default btn-block">Download Tag Hier</button>
<Child/>
)
}
}
And Child.js
import React from 'react';
export default class Child extends React.Component {
render() {
return (
<div ref='workbook'></div>
)
}
}
How can I trigger a click on the div element from the Child component when I click on the button element from the Parent component? I tried with ref but that won't work since the elements are on different components...