I am trying to copy this example using react data grid into my Typescript project. I created the following class to match the one provided....
import * as React from "react";
import ReactDataGrid from "react-data-grid";
interface PxGridProps {}
interface PxGridState {}
export default class PxGrid extends React.Component<PxGridProps, PxGridState>{
private _columns;
private _rows;
constructor(props) {
super(props);
this.props = props;
this.createRows();
this._columns = [
{ key: 'id', name: 'ID' },
{ key: 'title', name: 'Title' },
{ key: 'count', name: 'Count' } ];
return null;
}
createRows() {
let rows = [];
for (let i = 1; i < 1000; i++) {
rows.push({
id: i,
title: 'Title ' + i,
count: i * 1000
});
}
this._rows = rows;
}
rowGetter(i) {
return this._rows[i];
}
render() {
return (
<ReactDataGrid
minHeight={500}
columns={this._columns}
rowGetter={this.rowGetter.bind(this)}
rowsCount={this._rows.length}
/>
);
}
}
But when I try to run it I get
Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in. Check the render method of
PxGrid
.
If I replace out the render to something like this....
render() {
return (
<h1> Thing </h1>
);
}
It works fine. What am I getting wrong? The error message is not helping at all.