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 2.5.0 to 2.5.1

7

CHANGELOG.md

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

### [2.5.1](https://github.com/simoneb/axios-hooks/compare/v2.5.0...v2.5.1) (2021-03-28)
### Features
* **typings:** expose return type of useAxios ([3273ba1](https://github.com/simoneb/axios-hooks/commit/3273ba1fba2f7417bdc7844e77fe47ecd6fe2761))
## [2.5.0](https://github.com/simoneb/axios-hooks/compare/v2.5.0-0...v2.5.0) (2021-03-12)

@@ -7,0 +14,0 @@

28

package.json
{
"name": "axios-hooks",
"version": "2.5.0",
"version": "2.5.1",
"description": "axios-hooks",

@@ -46,6 +46,6 @@ "keywords": [

"@babel/cli": "7.13.10",
"@babel/core": "7.13.10",
"@babel/core": "7.13.13",
"@babel/plugin-transform-runtime": "7.13.10",
"@babel/preset-env": "7.13.10",
"@babel/preset-react": "7.12.13",
"@babel/preset-env": "7.13.12",
"@babel/preset-react": "7.13.13",
"@commitlint/cli": "12.0.1",

@@ -55,17 +55,17 @@ "@commitlint/config-conventional": "12.0.1",

"@testing-library/react-hooks": "4.0.1",
"@types/jest": "26.0.20",
"@types/jest": "26.0.22",
"@types/lru-cache": "5.1.0",
"@types/node": "12.20.5",
"@types/node": "12.20.7",
"@types/react": "17.0.3",
"@types/react-dom": "17.0.2",
"@types/react-dom": "17.0.3",
"axios": "0.21.1",
"babel-eslint": "10.1.0",
"cross-env": "7.0.3",
"eslint": "7.21.0",
"eslint": "7.23.0",
"eslint-config-prettier": "8.1.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-prettier": "3.3.1",
"eslint-plugin-react": "7.22.0",
"eslint-plugin-react": "7.23.1",
"eslint-plugin-react-hooks": "4.2.0",
"husky": "5.1.3",
"husky": "5.2.0",
"jest": "26.6.3",

@@ -75,8 +75,8 @@ "lint-staged": "10.5.4",

"prettier": "2.2.1",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-test-renderer": "17.0.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-test-renderer": "17.0.2",
"rimraf": "3.0.2",
"standard-version": "9.1.1",
"ts-jest": "26.5.3",
"ts-jest": "26.5.4",
"typescript": "4.2.3"

@@ -83,0 +83,0 @@ },

@@ -76,2 +76,3 @@ # axios-hooks

- [Refresh Behavior](#refresh-behavior)
- [Configuration](#configuration)

@@ -87,3 +88,10 @@ - [Manual Requests](#manual-requests)

`import useAxios, { configure, loadCache, serializeCache } from 'axios-hooks'`
```js
import useAxios, {
configure,
loadCache,
serializeCache,
makeUseAxios
} from 'axios-hooks'
```

@@ -114,8 +122,9 @@ ### useAxios(url|config, options)

- `useCache` ( `false` ) - Allows caching to be enabled/disabled for this "execute" function.
- `manualCancel()` - A function to cancel outstanding requests manually.
**Returns**
A promise containing the response. If the request is unsuccessful, an exception is thrown and must be handled manually.
A promise containing the response. If the request is unsuccessful, the promise reects and the rejection must be handled manually.
- `manualCancel()` - A function to cancel outstanding requests manually.
### configure({ cache, axios, defaultOptions })

@@ -164,2 +173,10 @@

## Refresh Behavior
The arguments provided to `useAxios(config[,options])` are watched for changes and compared using deep object comparison.
When they change, if the configuration allows a request to be fired (e.g. `manual:false`), any pending request is canceled and a new request is triggered.
Because of this, it's important to make sure that the arguments to `useAxios` preserve deep equality across component renders. This is often the case unless functions (e.g. axios interceptors or transformers) are provided to a configuration object. In that case, those functions need to be memoized or they will trigger a request execution at each render, leading to an infinite loop.
## Configuration

@@ -166,0 +183,0 @@

@@ -34,2 +34,11 @@ import {

export type UseAxiosResult<TResponse = any, TError = any> = [
ResponseValues<TResponse, TError>,
(
config?: AxiosRequestConfig,
options?: RefetchOptions
) => AxiosPromise<TResponse>,
() => void
]
export interface UseAxios {

@@ -39,10 +48,3 @@ <TResponse = any, TError = any>(

options?: Options
): [
ResponseValues<TResponse, TError>,
(
config?: AxiosRequestConfig,
options?: RefetchOptions
) => AxiosPromise<TResponse>,
() => void
]
): UseAxiosResult<TResponse, TError>

@@ -49,0 +51,0 @@ loadCache(data: any[]): void

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