question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError in Table._adjustBodyCells() due to array index out of bounds

See original GitHub issue

Expected Behavior

State transitions caused by click on anchors/buttons defined in table body work as expected and no errors are logged.

Actual Behavior

Browser console logs: TypeError: Cannot read property ‘innerText’ of undefined and clicking on any anchor defined in table body does not cause state transition anymore.

Sample code

class HelloWorldApp extends React.Component {

  constructor(props) {
    super(props);   
    this.state = { showLayer: false, item: undefined};
  }
  
  _onClickEditItem(item) {
    this.setState({showLayer: true, item: item})
  }

  _onSort(idx, asc) {
    console.log('onSort');
  }

  render() {
    const items = [{
      name: 'My Test Item1',
      shortName: 'test1',
      description: 'bla fasel bum'
    }, {
      name: 'My Test Item2',
      shortName: 'test2',
      description: 'Lorem isum ...'
    }, {
      name: 'My Test Item3',
      shortName: 'test3',
      description: 'foo bar baz'
    }, ];
    const sortIndex = 1,
      sortAscending = true;
    const headerLabels = [
      <FormattedMessage id="name" />,
      <FormattedMessage id="shortName" />,
      <FormattedMessage id="desc" />,
    ];
    
    let child = null;
    if(this.state.showLayer && this.state.item){
      child = <Layer modal={true}><h2>{this.state.item.name}</h2></Layer>
    }
    return (
      <App>
        <Title>Hello World</Title>
        <Table>
            <TableHeader labels={headerLabels} sortIndex={sortIndex} sortAscending={sortAscending} onSort={this._onSort} />
          <tbody>
            { items.map(item => {
              return             <TableRow key={item.shortName}>
        <td><Anchor onClick={() => this._onClickEditItem(item)}>{item.name}</Anchor></td>
        <td>{item.shortName}</td>
        <td>{item.description}</td>
      </TableRow>

            })}
          </tbody>
        </Table>
        {child}
      </App>
    );
  }
};

Steps to Reproduce

  1. Run code above with v1.3.0.
  2. Click on any anchor.
  3. Compare result with v1.3.1

Your Environment

  • Grommet version: 1.3.1
  • Browser Name and version: Chromium 56.0.2924.76 / Firefox 52
  • Operating System and version (desktop or mobile): Linux Mint 18.1 Cinnamon

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
alansouzaticommented, Mar 20, 2017

Shame on me, sorry folks. I’ve fixed this on https://github.com/grommet/grommet/commit/cd5b9ac23cfba79682dc805ff7a84367a9c0bb9b

I will soon release 1.3.2 with this fix, there are a couple of other items I will include in this release as well.

0reactions
h-arltcommented, Mar 21, 2017

Awesome! Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix the Array Index Out Of Bounds Excepiton in Java
The ArrayIndexOutOfBoundsException in Java is a runtime exception that occurs when an array is accessed with an illegal index.
Read more >
Array Index Out Of Bounds Exception - java - Stack Overflow
It leads to two issues, So you are missing first element (0th) in array, and trying to get 10th element (which is not...
Read more >
Array Index Out Of Bounds Exception in Java - GeeksforGeeks
The index of an array is an integer value that has value in the interval [0, n-1], where n is the size of...
Read more >
Index outside bounds of array error - Office - Microsoft Learn
"Index was outside the bounds of the array" error when you import data from multiple tables in a SQL Server database to an...
Read more >
Index was outside the bounds of the array - Microsoft Power BI ...
Solved: Hi @all, I am importing NetSuite Data into power bi using odbc connection. When the tables are imported into power bi using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found