Skip to content

Commit d61e2c7

Browse files
author
方永乐
committed
add notPreventFirstFetchOnBroswer to fetchData
1 parent 70fb26f commit d61e2c7

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

lib/fetchDataDecoretor.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,13 @@ var fetchData = function fetchData() {
5252
(0, _createClass3.default)(Enhance, [{
5353
key: 'componentDidMount',
5454
value: function componentDidMount() {
55-
if (isFirstLoadOnServer || notPreventFirstFetchOnBroswer) {
55+
if (isFirstLoadOnServer && !notPreventFirstFetchOnBroswer) {
5656
isFirstLoadOnServer = false;
57-
if (WrappedComponent.fetchData instanceof Function) {
58-
WrappedComponent.fetchData({
59-
dispatch: this.props.dispatch,
60-
match: this.props.match
61-
});
62-
}
57+
} else if (WrappedComponent.fetchData instanceof Function) {
58+
WrappedComponent.fetchData({
59+
dispatch: this.props.dispatch,
60+
match: this.props.match
61+
});
6362
}
6463
}
6564
}, {

src/fetchDataDecoretor.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ const fetchData = (notPreventFirstFetchOnBroswer = false) => {
77
return (WrappedComponent) => {
88
class Enhance extends React.Component {
99
componentDidMount() {
10-
if (isFirstLoadOnServer || notPreventFirstFetchOnBroswer) {
10+
if (isFirstLoadOnServer && !notPreventFirstFetchOnBroswer) {
1111
isFirstLoadOnServer = false;
12-
if (WrappedComponent.fetchData instanceof Function) {
13-
WrappedComponent.fetchData({
14-
dispatch: this.props.dispatch,
15-
match: this.props.match
16-
});
17-
}
12+
} else if (WrappedComponent.fetchData instanceof Function) {
13+
WrappedComponent.fetchData({
14+
dispatch: this.props.dispatch,
15+
match: this.props.match
16+
});
1817
}
1918
}
2019
render() {

0 commit comments

Comments
 (0)