mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
* utils for products generator * load test for each *.test.js file in packages folder * [test] unit test for utils/common * refactor all products with productGenerator for all examples * refactor folder structure * move component <Code /> to src/components/common * rename component file name
61 lines
1.1 KiB
JavaScript
61 lines
1.1 KiB
JavaScript
import React from 'react';
|
|
|
|
import { BootstrapTableful } from 'react-bootstrap-table2';
|
|
import Code from 'components/common/code-block';
|
|
import { productsGenerator } from 'utils/common';
|
|
|
|
const products = productsGenerator(5, (value, index) => ({
|
|
id: index,
|
|
name: `User Name ${index}`,
|
|
phone: 21009831 + index,
|
|
address: {
|
|
city: 'New York',
|
|
postCode: '1111-4512'
|
|
}
|
|
}));
|
|
|
|
const columns = [{
|
|
dataField: 'id',
|
|
text: 'User ID'
|
|
}, {
|
|
dataField: 'name',
|
|
text: 'User Name'
|
|
}, {
|
|
dataField: 'phone',
|
|
text: 'Phone'
|
|
}, {
|
|
dataField: 'address.city',
|
|
text: 'City'
|
|
}, {
|
|
dataField: 'address.postCode',
|
|
text: 'PostCode'
|
|
}];
|
|
|
|
const sourceCode = `\
|
|
const columns = [{
|
|
dataField: 'id',
|
|
text: 'User ID'
|
|
}, {
|
|
dataField: 'name',
|
|
text: 'User Name'
|
|
}, {
|
|
dataField: 'phone',
|
|
text: 'Phone'
|
|
}, {
|
|
dataField: 'address.city',
|
|
text: 'City'
|
|
}, {
|
|
dataField: 'address.postCode',
|
|
text: 'PostCode'
|
|
}];
|
|
|
|
<BootstrapTableful keyField='id' data={ products } columns={ columns } />
|
|
`;
|
|
|
|
export default () => (
|
|
<div>
|
|
<BootstrapTableful keyField="id" data={ products } columns={ columns } />
|
|
<Code>{ sourceCode }</Code>
|
|
</div>
|
|
);
|