|
1 | 1 | /* eslint react/prop-types: 0 */ |
2 | 2 | /* eslint react/require-default-props: 0 */ |
3 | 3 | /* eslint no-lonely-if: 0 */ |
| 4 | +/* eslint camelcase: 0 */ |
4 | 5 | import React from 'react'; |
5 | 6 | import EventEmitter from 'events'; |
6 | 7 | import Const from './const'; |
@@ -45,23 +46,6 @@ class StateProvider extends React.Component { |
45 | 46 | this.dataChangeListener.on('filterChanged', this.handleDataSizeChange); |
46 | 47 | } |
47 | 48 |
|
48 | | - componentWillReceiveProps(nextProps) { |
49 | | - const { custom } = nextProps.pagination.options; |
50 | | - |
51 | | - // user should align the page when the page is not fit to the data size when remote enable |
52 | | - if (this.isRemotePagination() || custom) { |
53 | | - if (typeof nextProps.pagination.options.page !== 'undefined') { |
54 | | - this.currPage = nextProps.pagination.options.page; |
55 | | - } |
56 | | - if (typeof nextProps.pagination.options.sizePerPage !== 'undefined') { |
57 | | - this.currSizePerPage = nextProps.pagination.options.sizePerPage; |
58 | | - } |
59 | | - if (typeof nextProps.pagination.options.totalSize !== 'undefined') { |
60 | | - this.dataSize = nextProps.pagination.options.totalSize; |
61 | | - } |
62 | | - } |
63 | | - } |
64 | | - |
65 | 49 | getPaginationProps = () => { |
66 | 50 | const { pagination: { options }, bootstrap4 } = this.props; |
67 | 51 | const { currPage, currSizePerPage, dataSize } = this; |
@@ -113,6 +97,23 @@ class StateProvider extends React.Component { |
113 | 97 |
|
114 | 98 | getPaginationRemoteEmitter = () => this.remoteEmitter || this.props.remoteEmitter; |
115 | 99 |
|
| 100 | + UNSAFE_componentWillReceiveProps(nextProps) { |
| 101 | + const { custom } = nextProps.pagination.options; |
| 102 | + |
| 103 | + // user should align the page when the page is not fit to the data size when remote enable |
| 104 | + if (this.isRemotePagination() || custom) { |
| 105 | + if (typeof nextProps.pagination.options.page !== 'undefined') { |
| 106 | + this.currPage = nextProps.pagination.options.page; |
| 107 | + } |
| 108 | + if (typeof nextProps.pagination.options.sizePerPage !== 'undefined') { |
| 109 | + this.currSizePerPage = nextProps.pagination.options.sizePerPage; |
| 110 | + } |
| 111 | + if (typeof nextProps.pagination.options.totalSize !== 'undefined') { |
| 112 | + this.dataSize = nextProps.pagination.options.totalSize; |
| 113 | + } |
| 114 | + } |
| 115 | + } |
| 116 | + |
116 | 117 | isRemotePagination = () => { |
117 | 118 | const e = {}; |
118 | 119 | this.remoteEmitter.emit('isRemotePagination', e); |
|
0 commit comments