I am using handsontable in my react component like the following:
class SchTable extends Component {
constructor(props) {
super(props);
this.hotSettings = scheduleTableSettings; //scheduleTableSettings is set and import from another file
this.hotTableComponent = React.createRef();
this.id = ‘hot’;
}
render() {
if(this.hotTableComponent.current) {
var hotInstance = this.hotTableComponent.current.hotInstance
hotInstance.addHook(‘afterOnCellMouseDown’, function(event, coords, td){let thisBlockObject = selectedSchedule.scheduleObject[coords.row];
const metaDataObject = thisBlockObject.blockRaceMetaData if(metaDataObject) { $('#Season').val(metaDataObject.season); $('#Type').val(metaDataObject.Type); $('#Level').val(metaDataObject.level); $('#IRT').val(metaDataObject.IRT); $('#Group').val(metaDataObject.group); $('#Heat').val(metaDataObject.heat); } }) } return ( <div> <HotTable id={this.id} ref={this.hotTableComponent} data={selectedSchedule} settings={this.hotSettings} /> </div> ) }
};
Am i using the hooks correctly by having it right before returning the JSX?
I also want to reference this handsontable from a different javascript file, how can i do that? For example, i have an onClick button in another react component that wants to grab all the data from this handsontable, how can the other react component reference this HotTable in this component in order to get all the data thats in this table? Thank you!