1
votes

I'm trying to create a table on my website using react-data-grid and getting the error of length of undefined. I have two other files for columns and rows, where I include them in the state.

<ReactDataGrid
  columns={this.state.columns}
  rowGetter={i => this.state.rows[i]}
  rowsCount={this.state.rows.length}
  onGridRowsUpdated={this.onGridRowsUpdated}
  enableCellSelect={true}
/>
2

2 Answers

0
votes
const { rows, columns } = this.state; 
if (!rows || !columns) return null;

return ( 
  <ReactDataGrid 
    columns= {columns} 
    rowGetter = {i => rows[i]} 
    rowsCount = {rows.length} 
    onGridRowsUpdated = {this.onGridRowsUpdated} 
    enableCellSelect 
  /> 
);
0
votes

In my case downgrading form 7.0.0-canary.39 to 5.0.4 worked. The rowGetter property is changed but for some reason the documentation is not updated.