Skip to content

Commit 4dc5e60

Browse files
committed
Merge branch 'chimericdream-master' into develop
2 parents bb42514 + d9acbac commit 4dc5e60

File tree

21 files changed

+105
-89
lines changed

21 files changed

+105
-89
lines changed

packages/react-bootstrap-table2-editor/src/context.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
/* eslint disable-next-line: 0 */
12
/* eslint react/prop-types: 0 */
23
/* eslint react/require-default-props: 0 */
4+
/* eslint camelcase: 0 */
5+
/* eslint react/no-unused-prop-types: 0 */
36
import React from 'react';
47
import PropTypes from 'prop-types';
58
import { CLICK_TO_CELL_EDIT, DBCLICK_TO_CELL_EDIT } from './const';
@@ -43,7 +46,7 @@ export default (
4346
};
4447
}
4548

46-
componentWillReceiveProps(nextProps) {
49+
UNSAFE_componentWillReceiveProps(nextProps) {
4750
if (nextProps.cellEdit && isRemoteCellEdit()) {
4851
if (nextProps.cellEdit.options.errorMessage) {
4952
this.setState(() => ({

packages/react-bootstrap-table2-editor/src/editing-cell.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* eslint no-return-assign: 0 */
33
/* eslint class-methods-use-this: 0 */
44
/* eslint jsx-a11y/no-noninteractive-element-interactions: 0 */
5+
/* eslint camelcase: 0 */
56
import React, { Component } from 'react';
67
import cs from 'classnames';
78
import PropTypes from 'prop-types';
@@ -51,7 +52,11 @@ export default (_, onStartEdit) =>
5152
};
5253
}
5354

54-
componentWillReceiveProps({ message }) {
55+
componentWillUnmount() {
56+
this.clearTimer();
57+
}
58+
59+
UNSAFE_componentWillReceiveProps({ message }) {
5560
if (_.isDefined(message)) {
5661
this.createTimer();
5762
this.setState(() => ({
@@ -60,10 +65,6 @@ export default (_, onStartEdit) =>
6065
}
6166
}
6267

63-
componentWillUnmount() {
64-
this.clearTimer();
65-
}
66-
6768
clearTimer() {
6869
if (this.indicatorTimer) {
6970
clearTimeout(this.indicatorTimer);

packages/react-bootstrap-table2-editor/test/context.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ describe('CellEditContext', () => {
117117
wrapper = shallow(shallowContext());
118118
wrapper.setState(initialState);
119119
wrapper.render();
120-
wrapper.instance().componentWillReceiveProps({});
120+
wrapper.instance().UNSAFE_componentWillReceiveProps({});
121121
});
122122

123123
it('should not set state.message', () => {
@@ -138,7 +138,7 @@ describe('CellEditContext', () => {
138138
wrapper = shallow(shallowContext());
139139
wrapper.setState(initialState);
140140
wrapper.render();
141-
wrapper.instance().componentWillReceiveProps({
141+
wrapper.instance().UNSAFE_componentWillReceiveProps({
142142
cellEdit: cellEditFactory(defaultCellEdit)
143143
});
144144
});
@@ -164,7 +164,7 @@ describe('CellEditContext', () => {
164164
wrapper = shallow(shallowContext(defaultCellEdit, true));
165165
wrapper.setState(initialState);
166166
wrapper.render();
167-
wrapper.instance().componentWillReceiveProps({
167+
wrapper.instance().UNSAFE_componentWillReceiveProps({
168168
cellEdit: cellEditFactory({
169169
...defaultCellEdit,
170170
errorMessage: message
@@ -190,7 +190,7 @@ describe('CellEditContext', () => {
190190
beforeEach(() => {
191191
wrapper = shallow(shallowContext(defaultCellEdit, true));
192192
wrapper.setState(initialState);
193-
wrapper.instance().componentWillReceiveProps({
193+
wrapper.instance().UNSAFE_componentWillReceiveProps({
194194
cellEdit: cellEditFactory({ ...defaultCellEdit })
195195
});
196196
wrapper.update();

packages/react-bootstrap-table2-filter/src/components/text.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint react/require-default-props: 0 */
22
/* eslint react/prop-types: 0 */
33
/* eslint no-return-assign: 0 */
4+
/* eslint camelcase: 0 */
45
import React, { Component } from 'react';
56
import { PropTypes } from 'prop-types';
67

@@ -41,16 +42,16 @@ class TextFilter extends Component {
4142
}
4243
}
4344

44-
componentWillReceiveProps(nextProps) {
45+
componentWillUnmount() {
46+
this.cleanTimer();
47+
}
48+
49+
UNSAFE_componentWillReceiveProps(nextProps) {
4550
if (nextProps.defaultValue !== this.props.defaultValue) {
4651
this.applyFilter(nextProps.defaultValue);
4752
}
4853
}
4954

50-
componentWillUnmount() {
51-
this.cleanTimer();
52-
}
53-
5455
filter(e) {
5556
e.stopPropagation();
5657
this.cleanTimer();

packages/react-bootstrap-table2-filter/src/context.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint react/prop-types: 0 */
22
/* eslint react/require-default-props: 0 */
3+
/* eslint camelcase: 0 */
34
import React from 'react';
45
import PropTypes from 'prop-types';
56

@@ -37,15 +38,6 @@ export default (
3738
}
3839
}
3940

40-
componentWillReceiveProps(nextProps) {
41-
// let nextData = nextProps.data;
42-
if (!isRemoteFiltering() && !_.isEqual(nextProps.data, this.data)) {
43-
this.doFilter(nextProps, this.isEmitDataChange);
44-
} else {
45-
this.data = nextProps.data;
46-
}
47-
}
48-
4941
onFilter(column, filterType, initialize = false) {
5042
return (filterVal) => {
5143
// watch out here if migration to context API, #334
@@ -90,6 +82,15 @@ export default (
9082
return this.data;
9183
}
9284

85+
UNSAFE_componentWillReceiveProps(nextProps) {
86+
// let nextData = nextProps.data;
87+
if (!isRemoteFiltering() && !_.isEqual(nextProps.data, this.data)) {
88+
this.doFilter(nextProps, this.isEmitDataChange);
89+
} else {
90+
this.data = nextProps.data;
91+
}
92+
}
93+
9394
doFilter(props, ignoreEmitDataChange = false) {
9495
const { dataChangeListener, data, columns } = props;
9596
const result = filters(data, columns, _)(this.currFilters);

packages/react-bootstrap-table2-filter/test/components/text.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ describe('Text Filter', () => {
144144
<TextFilter onFilter={ onFilter } column={ column } />
145145
);
146146
instance = wrapper.instance();
147-
instance.componentWillReceiveProps(nextProps);
147+
instance.UNSAFE_componentWillReceiveProps(nextProps);
148148
});
149149

150150
it('should setting state correctly when props.defaultValue is changed', () => {

packages/react-bootstrap-table2-paginator/src/data-context.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ class PaginationDataProvider extends Provider {
2121
isRemotePagination: PropTypes.func.isRequired
2222
}
2323

24-
componentWillReceiveProps(nextProps) {
25-
super.componentWillReceiveProps(nextProps);
24+
// eslint-disable-next-line camelcase, react/sort-comp
25+
UNSAFE_componentWillReceiveProps(nextProps) {
26+
super.UNSAFE_componentWillReceiveProps(nextProps);
2627
const { currSizePerPage } = this;
2728
const { custom, onPageChange } = nextProps.pagination.options;
2829

packages/react-bootstrap-table2-paginator/src/pagination-handler.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint react/prop-types: 0 */
2+
/* eslint camelcase: 0 */
23
import React, { Component } from 'react';
34

45
import pageResolver from './page-resolver';
@@ -12,7 +13,7 @@ export default WrappedComponent =>
1213
this.state = this.initialState();
1314
}
1415

15-
componentWillReceiveProps(nextProps) {
16+
UNSAFE_componentWillReceiveProps(nextProps) {
1617
const { dataSize, currSizePerPage } = nextProps;
1718
if (currSizePerPage !== this.props.currSizePerPage || dataSize !== this.props.dataSize) {
1819
const totalPages = this.calculateTotalPage(currSizePerPage, dataSize);

packages/react-bootstrap-table2-paginator/src/state-context.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint react/prop-types: 0 */
22
/* eslint react/require-default-props: 0 */
33
/* eslint no-lonely-if: 0 */
4+
/* eslint camelcase: 0 */
45
import React from 'react';
56
import EventEmitter from 'events';
67
import Const from './const';
@@ -45,23 +46,6 @@ class StateProvider extends React.Component {
4546
this.dataChangeListener.on('filterChanged', this.handleDataSizeChange);
4647
}
4748

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-
6549
getPaginationProps = () => {
6650
const { pagination: { options }, bootstrap4 } = this.props;
6751
const { currPage, currSizePerPage, dataSize } = this;
@@ -113,6 +97,23 @@ class StateProvider extends React.Component {
11397

11498
getPaginationRemoteEmitter = () => this.remoteEmitter || this.props.remoteEmitter;
11599

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+
116117
isRemotePagination = () => {
117118
const e = {};
118119
this.remoteEmitter.emit('isRemotePagination', e);

packages/react-bootstrap-table2-paginator/test/data-context.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ describe('PaginationDataContext', () => {
174174
data: [],
175175
pagination: { ...defaultPagination }
176176
};
177-
instance.componentWillReceiveProps(nextProps);
177+
instance.UNSAFE_componentWillReceiveProps(nextProps);
178178
});
179179

180180
it('should reset currPage to first page', () => {
@@ -195,7 +195,7 @@ describe('PaginationDataContext', () => {
195195
data: [],
196196
pagination: { ...defaultPagination, options: { onPageChange } }
197197
};
198-
instance.componentWillReceiveProps(nextProps);
198+
instance.UNSAFE_componentWillReceiveProps(nextProps);
199199
});
200200

201201
it('should call options.onPageChange correctly', () => {

0 commit comments

Comments
 (0)