0

onClick is being called like this:

<th onClick={() => this.handleClick(13)}>Und.</th>

When the line for(var key in this.state.tabs) gets executed, all of a sudden this is undefined? I suspect it has to do with it being shielded by being inside an immutable function? What's the fix?

class StockTable extends React.Component {
    constructor(props) {
        super(props);
        this.state = {hidden: [], stockItems: [] tabs: {}}; 
    }
    handleClick(index) {
        var table = document.getElementById('stocktable');

        console.log(index);
        if(13 == index)
        {
            console.log("starting unhiding elements of length: " + this.state.hidden.length + " \n");
            this.state.hidden.forEach(function(elem){
                console.log("Unhiding column " + elem + "\n");
                for(var key in this.state.tabs) {
Ivan
  • 7,448
  • 14
  • 69
  • 134

0 Answers0