I have a table component( external library ) and i want to add click event listener to table cells, so that i can copy the table cell content, this is the code i tried
componentDidMount(){
let tableCells = document.getElementsByClassName('Table__cell');
for (let i = 0; i < tableCells.length; i++) {
console.log(tableCells[i]);
tableCells[i].addEventListener('click', () => {
console.log(i);
}, false);
}
}
i know that this is not working because the collection length is 0 even though we have the collection. what is the solution for this ?