我正在使用 react-bootstrap-table2-paginator 将分页添加到我的 BootstrapTable。在表中添加分页部分时出现以下错误。我错过了一些进口或其他东西吗?
invariant.js:39 Uncaught Error: a.render(): A valid ReactComponent must be returned. You may have returned undefined, an array or some other invalid object.
这是组件的代码。
import React, { Component } from 'react';
import BootstrapTable from 'react-bootstrap-table-next';
import cellEditFactory from 'react-bootstrap-table2-editor';
import paginationFactory from 'react-bootstrap-table2-paginator';
class OverviewComponent extends Component {
constructor(props) {
super(props);
}
const products = [];
const columns = [{
dataField: 'id',
text: 'Product ID'
}, {
dataField: 'name',
text: 'Product Name'
}, {
dataField: 'price',
text: 'Product Price'
}];
function addProducts(quantity) {
const startId = products.length;
for (let i = 0; i < quantity; i++) {
const id = startId + i;
products.push({
id: id,
name: 'Item name ' + id,
price: 2100 + i
});
}
}
addProducts(12);
render() {
return (
<div className="container-fluid">
<div className="row">
<BootstrapTable
striped
hover
condensed
maxHeight={15}
keyField="id"
data={ products }
columns={ columns }
cellEdit={ cellEditFactory({ mode: 'dbclick' }) }
pagination={ paginationFactory() }
/>
</div>
</div>
);
}
}
export default OverviewComponent;
任何帮助,将不胜感激。谢谢