1

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 Answers2

0
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 
  /> 
);
simmer
  • 2,639
  • 1
  • 18
  • 22
Nowfal
  • 26
  • 1
0

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.

jainilvachhani
  • 708
  • 6
  • 13