react-timing-hooks
Advanced tools
Comparing version 1.3.2 to 1.4.0
@@ -5,2 +5,9 @@ # Changelog | ||
## [1.4.0](https://github.com/EricLambrecht/react-timing-hooks/compare/v1.3.2...v1.4.0) (2020-06-12) | ||
### Features | ||
* Add second param to useTimeoutEffect callback to manually clean the timeout ([428c3f7](https://github.com/EricLambrecht/react-timing-hooks/commit/428c3f759bb3a6e117b288c484e5cfe76e396c49)) | ||
### [1.3.2](https://github.com/EricLambrecht/react-timing-hooks/compare/v1.3.1...v1.3.2) (2020-03-28) | ||
@@ -7,0 +14,0 @@ |
@@ -9,3 +9,7 @@ import { useRef, useCallback, useEffect, useState } from 'react'; | ||
useEffect(() => { | ||
return effect(timeoutFunc); | ||
return effect(timeoutFunc, () => { | ||
if (timeoutId.current) { | ||
clearTimeout(timeoutId.current); | ||
} | ||
}); | ||
}, deps); | ||
@@ -12,0 +16,0 @@ useEffect(() => { |
@@ -13,3 +13,7 @@ 'use strict'; | ||
react.useEffect(() => { | ||
return effect(timeoutFunc); | ||
return effect(timeoutFunc, () => { | ||
if (timeoutId.current) { | ||
clearTimeout(timeoutId.current); | ||
} | ||
}); | ||
}, deps); | ||
@@ -16,0 +20,0 @@ react.useEffect(() => { |
export declare type TimeoutCreator = (handler: () => unknown, timeout: number) => any; | ||
export declare type TimeoutId = ReturnType<typeof setTimeout>; | ||
export declare type TimeoutEffectCallback = (timeoutFunc: TimeoutCreator) => void | (() => void | undefined); | ||
export declare type TimeoutEffectCallback = (timeoutFunc: TimeoutCreator, clearFunc: () => void) => void | (() => void | undefined); |
{ | ||
"name": "react-timing-hooks", | ||
"version": "1.3.2", | ||
"version": "1.4.0", | ||
"description": "React hooks for setTimeout, setInterval, requestAnimationFrame, requestIdleCallback", | ||
@@ -54,3 +54,3 @@ "main": "dist/index.js", | ||
"cli-confirm": "^1.0.1", | ||
"commitizen": "^4.0.3", | ||
"commitizen": "^4.1.2", | ||
"emoji-cz": "^0.3.1", | ||
@@ -63,3 +63,3 @@ "jest": "^25.1.0", | ||
"react-test-renderer": "^16.13.1", | ||
"replace": "^1.1.5", | ||
"replace": "^1.2.0", | ||
"rimraf": "^3.0.2", | ||
@@ -66,0 +66,0 @@ "rollup": "^2.1.0", |
@@ -15,5 +15,3 @@ [![npm](https://flat.badgen.net/npm/v/react-timing-hooks)](https://www.npmjs.com/package/react-timing-hooks) | ||
* `requestIdleCallback` | ||
* Additional utility hooks like | ||
* `useTimer` | ||
* `useAnimationFrameLoop` | ||
* Including "effect" versions and utility hooks like `useTimer`, `useAnimationFrameLoop` | ||
* Full Typescript support | ||
@@ -20,0 +18,0 @@ * [Lightweight](https://bundlephobia.com/result?p=react-timing-hooks) (less than 1KB minzipped, no external dependencies) |
Sorry, the diff of this file is not supported yet
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
30435
393
123