Skip to content

Commit 6ccd1bc

Browse files
authored
Merge pull request #116 from kmiyauchi/master
FilterList: Fixed the issue of onDisplay invocation...
2 parents 688e322 + 2c64c0a commit 6ccd1bc

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

lib/FilteredList/List.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ var List = function (_React$Component) {
8888
}
8989
}, {
9090
key: 'componentDidUpdate',
91-
value: function componentDidUpdate() {
91+
value: function componentDidUpdate(prevProps) {
9292
var _props3 = this.props,
9393
onDisplay = _props3.onDisplay,
9494
onNumOfListChange = _props3.onNumOfListChange,
@@ -102,7 +102,7 @@ var List = function (_React$Component) {
102102
/* Only setState and invoke callbacks when the state is changed to avoid infinite loop */
103103

104104

105-
if (activeData.length !== this.state.numOfItems || startingArticle !== this.state.startingArticle || lastArticle !== this.state.lastArticle) {
105+
if (activeData.length !== this.state.numOfItems || startingArticle !== this.state.startingArticle || lastArticle !== this.state.lastArticle || prevProps.data.length !== data.length) {
106106
this.updateStatus();
107107
}
108108
}

src/FilteredList/List.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,15 @@ class List extends React.Component {
5353
return populatedContainer;
5454
}
5555

56-
componentDidUpdate() {
56+
componentDidUpdate(prevProps) {
5757
const { onDisplay, onNumOfListChange, data } = this.props;
5858
const { activeData, startingArticle, lastArticle } = calcActiveData(this.props);
5959

6060
/* Only setState and invoke callbacks when the state is changed to avoid infinite loop */
6161
if ( activeData.length !== this.state.numOfItems ||
6262
startingArticle !== this.state.startingArticle ||
63-
lastArticle !== this.state.lastArticle) {
63+
lastArticle !== this.state.lastArticle ||
64+
prevProps.data.length !== data.length) {
6465
this.updateStatus();
6566
}
6667
}

0 commit comments

Comments
 (0)