I try to run fixed data table with this code.
var MyCompi=React.createClass({
getInitialState: function() {
return{ rows : [{"id":1,"first_name":"William","last_name":"Elliott","email":"welliott0@wisc.edu",
"country":"Argentina","ip_address":"247.180.226.89"},
{"id":2,"first_name":"Carl","last_name":"Ross","email":"cross1@mlb.com",
"country":"South Africa","ip_address":"27.146.70.36"},
{"id":3,"first_name":"Jeremy","last_name":"Scott","email":"jscott2@cbsnews.com",
"country":"Colombia","ip_address":"103.52.74.225"}] };
},
render:function(){
return(
<Table
height={this.state.rows.length * 300}
width={1150}
rowsCount={this.state.rows.length}
rowHeight={30}
headerHeight={30}
rowGetter={function(rowIndex) {return this.state.rows[rowIndex]; }}>
<Column dataKey="id" width={50} label="Id" />
<Column dataKey="first_name" width={200} label="First Name" />
<Column dataKey="last_name" width={200} label="Last Name" />
</Table>
);
}
});
ReactDOM.render(<MyCompi/>
,
document.getElementById('root')
);
But I get error.
- Uncaught TypeError: Cannot read property 'rows' of undefined
When I set the getInitialState (rows) like that "rows[]" the exception goes away.But I get empty datatable in that case.
I really confuesed about that.Any help?