From a6e2f0f8f844e8a1775a6b4f57b8648d8b1cebb8 Mon Sep 17 00:00:00 2001 From: Allen Date: Sat, 6 Oct 2018 23:42:55 +0800 Subject: [PATCH] fix #589 (#594) --- .../src/context.js | 3 +++ .../test/context.test.js | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/packages/react-bootstrap-table2-paginator/src/context.js b/packages/react-bootstrap-table2-paginator/src/context.js index eb58ceb..d5ffb96 100644 --- a/packages/react-bootstrap-table2-paginator/src/context.js +++ b/packages/react-bootstrap-table2-paginator/src/context.js @@ -68,6 +68,9 @@ export default ( currPage = newPage; needNewState = true; } + } else { + this.currPage = nextProps.pagination.options.page; + this.currSizePerPage = nextProps.pagination.options.sizePerPage; } if (needNewState) { diff --git a/packages/react-bootstrap-table2-paginator/test/context.test.js b/packages/react-bootstrap-table2-paginator/test/context.test.js index 9d13658..d72caea 100644 --- a/packages/react-bootstrap-table2-paginator/test/context.test.js +++ b/packages/react-bootstrap-table2-paginator/test/context.test.js @@ -160,6 +160,27 @@ describe('PaginationContext', () => { }); }); + describe('when remote pagination is enable', () => { + beforeEach(() => { + wrapper = shallow(shallowContext({ ...defaultPagination }, true)); + instance = wrapper.instance(); + wrapper.render(); + nextProps = { + data, + pagination: { ...defaultPagination, options: { page: 3, sizePerPage: 5 } } + }; + instance.componentWillReceiveProps(nextProps); + }); + + it('should always set currPage from nextProps.pagination.options.page', () => { + expect(instance.currPage).toEqual(nextProps.pagination.options.page); + }); + + it('should always set currSizePerPage from nextProps.pagination.options.sizePerPage', () => { + expect(instance.currSizePerPage).toEqual(nextProps.pagination.options.sizePerPage); + }); + }); + describe('when page is not align', () => { beforeEach(() => { wrapper = shallow(shallowContext({