Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-fetch-hook

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-fetch-hook - npm Package Compare versions

Comparing version 1.3.4 to 1.3.5

4

dist/useFetch.js

@@ -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();

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc