New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

axios-hooks

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios-hooks - npm Package Compare versions

Comparing version 1.4.1 to 1.5.0-0

src/index.test.ssr.ts

12

CHANGELOG.md

@@ -5,2 +5,14 @@ # Changelog

## [1.5.0-0](https://github.com/simoneb/axios-hooks/compare/v1.4.1...v1.5.0-0) (2019-10-22)
### Features
* maintain referential integrity of refetch function ([1c4c5ac](https://github.com/simoneb/axios-hooks/commit/1c4c5acdd56f5597269a0d9ae321daf2e587f5c8))
### Bug Fixes
* typing of serializeCache function ([3040b80](https://github.com/simoneb/axios-hooks/commit/3040b80696e7ab9df07f64ac6c5beacc276178cd))
### [1.4.1](https://github.com/simoneb/axios-hooks/compare/v1.3.0...v1.4.1) (2019-10-19)

@@ -7,0 +19,0 @@

17

es/index.js

@@ -209,2 +209,3 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";

var stringifiedConfig = JSON.stringify(config);
options = _extends({

@@ -228,10 +229,12 @@ manual: false,

executeRequest(config, options, dispatch);
}
}, [JSON.stringify(config)]);
return [state, function (configOverride, options) {
options = _extends({
} // eslint-disable-next-line react-hooks/exhaustive-deps
}, [stringifiedConfig]);
var refetch = React.useCallback(function (configOverride, options) {
return executeRequest(_extends({}, config, {}, configOverride), _extends({
useCache: false
}, options);
return executeRequest(_extends({}, config, {}, configOverride), options, dispatch);
}];
}, options), dispatch);
}, // eslint-disable-next-line react-hooks/exhaustive-deps
[stringifiedConfig]);
return [state, refetch];
}

@@ -41,3 +41,3 @@ import {

export function loadCache(data: any[]): void
export function serializeCache(): any[]
export function serializeCache(): Promise<any[]>

@@ -44,0 +44,0 @@ export function configure(options: ConfigureOptions): void

@@ -233,2 +233,3 @@ "use strict";

var stringifiedConfig = JSON.stringify(config);
options = (0, _extends3["default"])({

@@ -252,11 +253,14 @@ manual: false,

executeRequest(config, options, dispatch);
}
}, [JSON.stringify(config)]);
} // eslint-disable-next-line react-hooks/exhaustive-deps
return [state, function (configOverride, options) {
options = (0, _extends3["default"])({
}, [stringifiedConfig]);
var refetch = _react["default"].useCallback(function (configOverride, options) {
return executeRequest((0, _extends3["default"])({}, config, {}, configOverride), (0, _extends3["default"])({
useCache: false
}, options);
return executeRequest((0, _extends3["default"])({}, config, {}, configOverride), options, dispatch);
}];
}, options), dispatch);
}, // eslint-disable-next-line react-hooks/exhaustive-deps
[stringifiedConfig]);
return [state, refetch];
}
{
"name": "axios-hooks",
"version": "1.4.1",
"version": "1.5.0-0",
"description": "axios-hooks",

@@ -43,35 +43,36 @@ "keywords": [

"react": "^16.8.0-0",
"axios": "^0.18.0"
"axios": "^0.18.0 || ^0.19.0"
},
"devDependencies": {
"@babel/cli": "^7.6.4",
"@babel/core": "^7.6.4",
"@babel/plugin-transform-runtime": "^7.6.2",
"@babel/preset-env": "^7.6.3",
"@testing-library/react-hooks": "^2.0.3",
"@types/jest": "^24.0.18",
"@types/lru-cache": "^5.1.0",
"@types/node": "^12.7.12",
"@types/react": "^16.9.5",
"@types/react-dom": "^16.9.1",
"axios": "^0.19.0",
"babel-eslint": "^10.0.3",
"cross-env": "^6.0.3",
"cz-conventional-changelog": "^3.0.2",
"eslint": "^6.5.1",
"eslint-config-prettier": "^6.4.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-prettier": "^3.1.1",
"husky": "^3.0.8",
"jest": "^24.9.0",
"lint-staged": "^9.4.2",
"npm-run-all": "^4.1.5",
"prettier": "^1.18.2",
"react": "^16.10.2",
"react-dom": "^16.10.2",
"react-test-renderer": "^16.10.2",
"rimraf": "^3.0.0",
"standard-version": "^7.0.0",
"ts-jest": "^24.1.0",
"typescript": "^3.6.4"
"@babel/cli": "7.6.4",
"@babel/core": "7.6.4",
"@babel/plugin-transform-runtime": "7.6.2",
"@babel/preset-env": "7.6.3",
"@testing-library/react-hooks": "2.0.3",
"@types/jest": "24.0.18",
"@types/lru-cache": "5.1.0",
"@types/node": "12.7.12",
"@types/react": "16.9.5",
"@types/react-dom": "16.9.1",
"axios": "0.19.0",
"babel-eslint": "10.0.3",
"cross-env": "6.0.3",
"cz-conventional-changelog": "3.0.2",
"eslint": "6.5.1",
"eslint-config-prettier": "6.4.0",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-prettier": "3.1.1",
"eslint-plugin-react-hooks": "2.1.2",
"husky": "3.0.8",
"jest": "24.9.0",
"lint-staged": "9.4.2",
"npm-run-all": "4.1.5",
"prettier": "1.18.2",
"react": "16.10.2",
"react-dom": "16.10.2",
"react-test-renderer": "16.10.2",
"rimraf": "3.0.0",
"standard-version": "7.0.0",
"ts-jest": "24.1.0",
"typescript": "3.6.4"
},

@@ -78,0 +79,0 @@ "husky": {

@@ -41,3 +41,3 @@ import {

export function loadCache(data: any[]): void
export function serializeCache(): any[]
export function serializeCache(): Promise<any[]>

@@ -44,0 +44,0 @@ export function configure(options: ConfigureOptions): void

@@ -126,2 +126,4 @@ import React from 'react'

const stringifiedConfig = JSON.stringify(config)
options = { manual: false, useCache: true, ...options }

@@ -142,12 +144,18 @@

}
}, [JSON.stringify(config)])
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [stringifiedConfig])
return [
state,
const refetch = React.useCallback(
(configOverride, options) => {
options = { useCache: false, ...options }
return executeRequest(
{ ...config, ...configOverride },
{ useCache: false, ...options },
dispatch
)
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[stringifiedConfig]
)
return executeRequest({ ...config, ...configOverride }, options, dispatch)
}
]
return [state, refetch]
}

@@ -88,2 +88,14 @@ import { renderHook, act } from '@testing-library/react-hooks'

it('should return the same reference to the fetch function', async () => {
axios.mockResolvedValue({ data: 'whatever' })
const { result, rerender } = renderHook(() => useAxios(''))
const firstRefetch = result.current[1]
rerender()
expect(result.current[1]).toBe(firstRefetch)
})
describe('manual option', () => {

@@ -90,0 +102,0 @@ it('should set loading to false', async () => {

@@ -88,2 +88,14 @@ import { renderHook, act } from '@testing-library/react-hooks'

it('should return the same reference to the fetch function', async () => {
axios.mockResolvedValue({ data: 'whatever' })
const { result, rerender } = renderHook(() => useAxios(''))
const firstRefetch = result.current[1]
rerender()
expect(result.current[1]).toBe(firstRefetch)
})
describe('manual option', () => {

@@ -90,0 +102,0 @@ it('should set loading to false', async () => {

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