Skip to content

Commit 092fee1

Browse files
committed
Fix: perform new request only if props are changed
1 parent dc257a2 commit 092fee1

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-http-request",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "React component exposes network request functionality",
55
"main": "lib/index.js",
66
"scripts": {

src/index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class Request extends React.Component {
2121
this.performRequest(this.props);
2222
}
2323
componentWillReceiveProps(nextProps) {
24+
if (JSON.stringify(this.props) === JSON.stringify(nextProps)) {
25+
return;
26+
}
27+
2428
this.request.abort();
2529
this.performRequest(nextProps);
2630
}
@@ -137,7 +141,7 @@ Request.propTypes = {
137141
withCredentials: React.PropTypes.bool,
138142
buffer: React.PropTypes.bool,
139143
attach: React.PropTypes.array,
140-
fieldss: React.PropTypes.array,
144+
fields: React.PropTypes.array,
141145
onRequest: React.PropTypes.func,
142146
};
143147

0 commit comments

Comments
 (0)