Skip to content

Conversation

@AllenFang
Copy link
Member

@AllenFang AllenFang added this to the 0.1.0 milestone Nov 8, 2017
@AllenFang AllenFang requested a review from chunming-c November 8, 2017 15:39
package.json Outdated
"prop-types": "^15.5.10",
"react": "^15.6.1",
"react-dom": "^15.6.1"
"react": "^16.0.0",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package.json Outdated
"react": "^15.0.0",
"react-dom": "^15.0.0"
"react": "^15.0.0 || ^16",
"react-dom": "^15.0.0 || ^16"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll consider to make ^16 only as peer when we release, but I need some test

text: 'Product Price'
}];
<BootstrapTable keyField='id' data={ products } columns={ columns } />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forget to update code

text: 'Product Price'
}];
<BootstrapTable keyField='id' data={ products } columns={ columns } />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgot to update code

@@ -0,0 +1,134 @@
/* eslint no-mixed-operators: 0 */
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this class is main class for calculate page information by props

componentWillReceiveProps(nextProps) {
const { dataSize, currSizePerPage } = nextProps;

if (currSizePerPage !== this.props.currSizePerPage || dataSize !== this.props.dataSize) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currSizePerPage and dataSize will effect on totalPages and lastPage

data: store.getByCurrPage(currPage, currSizePerPage)
});

return [
Copy link
Member Author

@AllenFang AllenFang Nov 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a kind of different than previous wrapper,

  1. In this class, I export a factory function instead of HoC(this factory function will create a HoC)

  2. This factory function will have two args: baseElement and Const which are passed from react-bootstrap-table2(table-factory)

  3. This HOC component is not render next element, instead, I render base element and Pagination component together

const base = baseElement({
...this.props,
key: 'table',
data: store.getByCurrPage(currPage, currSizePerPage)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slice data by page here

} else if (this.props.columns.filter(col => col.sort).length > 0) {
return wrapWithSort(baseProps);
} else if (this.props.pagination) {
return wrapWithPagination(baseProps);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use wrapper as usual

if (props.pagination) {
const { wrapper } = props.pagination;
const PaginationBase = wrapper(pureTable, Const);
return React.createElement(PaginationBase, { ...props });
Copy link
Member Author

@AllenFang AllenFang Nov 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. get pagination wrapper from props
  2. call the wrapper function (wrapper is a factory function)
<BootstrapTable keyField='id' data={ products } columns={ columns } pagination={ paginator } />
`;

class BasicPaginationTable extends React.PureComponent {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wondered what kind of difficulties you faced and you selected PureComponent here :)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing there, I just test some state change manually but forgot to remove it, thanks this reminder

@AllenFang
Copy link
Member Author

umm.... huge PR, review by commit will be little better lol.

@AllenFang AllenFang force-pushed the feat/pagination branch 4 times, most recently from d5d2da5 to 3ece5ff Compare November 16, 2017 01:23
@AllenFang AllenFang changed the title [WIP] Implement Pagination Implement Pagination Nov 19, 2017
@AllenFang
Copy link
Member Author

@Chun-MingChen after merged, you are suppose to run yarn install again on your local.

@AllenFang AllenFang merged commit 3c88364 into develop Nov 19, 2017
@AllenFang AllenFang deleted the feat/pagination branch November 19, 2017 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants