3

ここに固定データテーブルの例があります:

https://github.com/facebook/fixed-data-table/blob/master/examples/FilterExample.js

しかし、私はそれを理解するのに苦労しています。

ES5 で Fixed Data Table に関するコードをいくつか書きました。「フィルタリング」の例をコードに追加したいと思います。しかし、その例は ES6 です。

ES6 を ES5 に変換する方法を教えてください。

これが私のコードです:

var 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"},

// more data
];

ReactDOM.render(
    <Table
      height={rows.length * 30}
      width={1150}
      rowsCount={rows.length}
      rowHeight={30}
      headerHeight={30}
      rowGetter={function(rowIndex) {return 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" />
      <Column  dataKey="email" width={400} label="e-mail" />
      <Column  dataKey="country" width={300} label="Country" />

    </Table>,
    document.getElementById('root')
);
4

1 に答える 1

2

「クラス」を使用する代わりに、を使用できますReact.createClass。次に例を示します。

var FilterExample = React.createClass({
  // constructor
  getInitialState: function() {
    this._dataList = new FakeObjectDataListStore(2000);    
    this._onFilterChange = this._onFilterChange.bind(this);
    return {
      filteredDataList: this._dataList,
    };
  },
  ...
  render: function() {
    <Table
    ...
    </Table>,
    document.getElementById('root')
  }
});
于 2016-01-11T19:40:38.233 に答える