react-fetch-hook
Advanced tools
Comparing version 1.3.4 to 1.3.5
@@ -32,5 +32,5 @@ "use strict"; | ||
var _preventCallFetch = _depends ? _depends.reduce(function (accumulator, currentValue) { | ||
var _preventCallFetch = _depends && _depends.reduce(function (accumulator, currentValue) { | ||
return accumulator || !currentValue; | ||
}, false) : preventCallFetch; | ||
}, false) || preventCallFetch; | ||
@@ -37,0 +37,0 @@ if (_preventCallFetch) { |
{ | ||
"name": "react-fetch-hook", | ||
"version": "1.3.4", | ||
"version": "1.3.5", | ||
"description": "React fetch hook", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -106,2 +106,25 @@ import React from "react"; | ||
it("call with url, options with preventCallFetch and depends", async () => { | ||
fetch.mockResponse(JSON.stringify({ data: "12345" })); | ||
const options = { | ||
headers: { | ||
Accept: "application/json, application/xml, text/plain, text/html, *.*", | ||
"Content-Type": "application/json; charset=utf-8" | ||
} | ||
}; | ||
const Component = () => { | ||
const result = useFetch("https://google.com", { ...options, depends: [true], preventCallFetch: true }); | ||
return <div>{result.data && result.data.data}</div>; | ||
}; | ||
const { container, rerender } = render(<Component />); | ||
await wait(() => { | ||
rerender(<Component />); | ||
expect(fetch.mock.calls.length).toEqual(0); | ||
}); | ||
}); | ||
it("call with url, options with depends", async () => { | ||
@@ -108,0 +131,0 @@ fetch.mockResponse(JSON.stringify({ data: "12345" })); |
@@ -31,5 +31,5 @@ // @flow | ||
const _depends = (specialOptions && specialOptions.depends) || depends; | ||
const _preventCallFetch = _depends | ||
? _depends.reduce((accumulator, currentValue) => accumulator || !currentValue, false) | ||
: preventCallFetch; | ||
const _preventCallFetch = | ||
(_depends && _depends.reduce((accumulator, currentValue) => accumulator || !currentValue, false)) || | ||
preventCallFetch; | ||
if (_preventCallFetch) { | ||
@@ -36,0 +36,0 @@ return Promise.resolve(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28605
528
33