diff --git a/CHANGELOG.md b/CHANGELOG.md index 8be3f6d..fc1972d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +### v3.0.1 (2018/4/24) + +**Bug Fixes** + +* Fixes a bug where `isLazy` would sometimes be computed using previous + props rather than the current props. + ### v3.0.0 (2018/4/24) > Although the changes in this release are technically breaking, they are unlikely to diff --git a/package.json b/package.json index d5970ba..d405b8f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-request", - "version": "3.0.0", + "version": "3.0.1", "description": "Declarative HTTP requests with React.", "main": "lib/index.js", "module": "es/index.js", diff --git a/src/fetch.js b/src/fetch.js index 7ea2f17..7166045 100644 --- a/src/fetch.js +++ b/src/fetch.js @@ -74,8 +74,8 @@ export class Fetch extends React.Component { // We default to being lazy for "write" requests, // such as POST, PATCH, DELETE, and so on. - isLazy = props => { - const { lazy, method } = props || this.props; + isLazy = () => { + const { lazy, method } = this.props; return typeof lazy === 'undefined' ? !this.isReadRequest(method) : lazy; }; @@ -121,7 +121,7 @@ export class Fetch extends React.Component { method: prevProps.method.toUpperCase() }); - if (currentRequestKey !== prevRequestKey && !this.isLazy(prevProps)) { + if (currentRequestKey !== prevRequestKey && !this.isLazy()) { this.fetchData({ requestKey: currentRequestKey }); diff --git a/test/.eslintrc b/test/.eslintrc index 83e8b92..906c2f5 100644 --- a/test/.eslintrc +++ b/test/.eslintrc @@ -1,4 +1,7 @@ { + "extends": [ + "../.eslintrc" + ], "env": { "jest": true, "node": true