Skip to content

Commit 89d3678

Browse files
committed
search fixed
1 parent 9f0c98c commit 89d3678

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

bundle.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -30481,11 +30481,15 @@
3048130481
}, {
3048230482
key: 'componentWillReceiveProps',
3048330483
value: function componentWillReceiveProps(nextProps) {
30484+
console.log("componentWillReceiveProps", this.props, nextProps);
3048430485
if (this.isRequestPrettyPermalink(nextProps)) {
30486+
console.log('isRequestPrettyPermalink');
3048530487
this.props.fetchPost(nextProps.prettyPermalink);
3048630488
} else if (this.isSearchRequest(nextProps)) {
30489+
console.log('isSearchRequest');
3048730490
this.props.searchSite(nextProps.searchTerm);
3048830491
} else if (this.isRequestForIndex(nextProps)) {
30492+
console.log('isRequestForIndex');
3048930493
this.props.fetchPosts(nextProps.pageNum);
3049030494
}
3049130495
}
@@ -30502,7 +30506,7 @@
3050230506
}, {
3050330507
key: 'isRequestForIndex',
3050430508
value: function isRequestForIndex(nextProps) {
30505-
return this.props.pageNum !== nextProps.pageNum || 'undefined' === typeof nextProps.prettyPermalink && 'undefined' === typeof nextProps.searchTerm;
30509+
return this.props.pageNum !== nextProps.pageNum || 'undefined' === typeof nextProps.prettyPermalink && 'undefined' === typeof nextProps.searchTerm && (this.props.prettyPermalink !== nextProps.prettyPermalink || this.props.searchTerm !== nextProps.searchTerm);
3050630510
}
3050730511
}, {
3050830512
key: 'componentWillMount',

src/containers/main.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ class Main extends Component {
1212
}
1313

1414
componentWillReceiveProps(nextProps) {
15+
console.log("componentWillReceiveProps", this.props, nextProps);
1516
if (this.isRequestPrettyPermalink(nextProps)) {
17+
console.log('isRequestPrettyPermalink');
1618
this.props.fetchPost(nextProps.prettyPermalink);
1719
} else if (this.isSearchRequest(nextProps)) {
20+
console.log('isSearchRequest');
1821
this.props.searchSite(nextProps.searchTerm);
1922
} else if (this.isRequestForIndex(nextProps)) {
23+
console.log('isRequestForIndex');
2024
this.props.fetchPosts(nextProps.pageNum);
2125
}
2226
}
@@ -31,7 +35,8 @@ class Main extends Component {
3135

3236
isRequestForIndex(nextProps) {
3337
return this.props.pageNum !== nextProps.pageNum
34-
|| ('undefined' === typeof nextProps.prettyPermalink && 'undefined' === typeof nextProps.searchTerm);
38+
|| ('undefined' === typeof nextProps.prettyPermalink && 'undefined' === typeof nextProps.searchTerm)
39+
&& (this.props.prettyPermalink !== nextProps.prettyPermalink || this.props.searchTerm !== nextProps.searchTerm);
3540
}
3641

3742
componentWillMount() {

0 commit comments

Comments
 (0)