react-timing-hooks
Advanced tools
Comparing version 1.2.0 to 1.3.1
@@ -5,2 +5,16 @@ # Changelog | ||
### [1.3.1](https://github.com/EricLambrecht/react-timing-hooks/compare/v1.3.0...v1.3.1) (2020-03-27) | ||
### Bug Fixes | ||
* Add missing docs for new hook "useTimer" ([e7b30fd](https://github.com/EricLambrecht/react-timing-hooks/commit/e7b30fd9455720e2058188eb82b3907cab214bb7)) | ||
## [1.3.0](https://github.com/EricLambrecht/react-timing-hooks/compare/v1.2.0...v1.3.0) (2020-03-27) | ||
### Features | ||
* Add utility hook "useTimer" ([1874244](https://github.com/EricLambrecht/react-timing-hooks/commit/18742443a2316ae2902e972b2a5879155e5fa375)) | ||
## [1.2.0](https://github.com/EricLambrecht/react-timing-hooks/compare/v1.1.1...v1.2.0) (2020-03-27) | ||
@@ -7,0 +21,0 @@ |
import useTimeoutEffect from './timeout/useTimeoutEffect'; | ||
import useTimeout from './timeout/useTimeout'; | ||
import useInterval from './interval/useInterval'; | ||
import useTimer from './interval/useTimer'; | ||
import useIdleCallbackEffect from './idle-callback/useIdleCallbackEffect'; | ||
@@ -10,2 +11,2 @@ import useIdleCallback from './idle-callback/useIdleCallback'; | ||
import { IdleCallbackEffectCallback } from './idle-callback/types'; | ||
export { useAnimationFrame, useAnimationFrameLoop, useIdleCallback, useIdleCallbackEffect, useInterval, useTimeout, useTimeoutEffect, IdleCallbackEffectCallback, TimeoutEffectCallback, }; | ||
export { useAnimationFrame, useAnimationFrameLoop, useIdleCallback, useIdleCallbackEffect, useInterval, useTimer, useTimeout, useTimeoutEffect, IdleCallbackEffectCallback, TimeoutEffectCallback, }; |
@@ -63,2 +63,8 @@ import { useRef, useCallback, useEffect, useState } from 'react'; | ||
const useTimer = (start = 0) => { | ||
const [val, setVal] = useState(start); | ||
useInterval(() => setVal(val + 1), 1000); | ||
return val; | ||
}; | ||
const useIdleCallbackEffect = (effect, deps) => { | ||
@@ -154,2 +160,2 @@ if (!window.requestIdleCallback) { | ||
export { useAnimationFrame, useAnimationFrameLoop, useIdleCallback, useIdleCallbackEffect, useInterval, useTimeout, useTimeoutEffect }; | ||
export { useAnimationFrame, useAnimationFrameLoop, useIdleCallback, useIdleCallbackEffect, useInterval, useTimeout, useTimeoutEffect, useTimer }; |
@@ -67,2 +67,8 @@ 'use strict'; | ||
const useTimer = (start = 0) => { | ||
const [val, setVal] = react.useState(start); | ||
useInterval(() => setVal(val + 1), 1000); | ||
return val; | ||
}; | ||
const useIdleCallbackEffect = (effect, deps) => { | ||
@@ -165,1 +171,2 @@ if (!window.requestIdleCallback) { | ||
exports.useTimeoutEffect = useTimeoutEffect; | ||
exports.useTimer = useTimer; |
{ | ||
"name": "react-timing-hooks", | ||
"version": "1.2.0", | ||
"version": "1.3.1", | ||
"description": "React hooks for setTimeout, setInterval, requestAnimationFrame, requestIdleCallback", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -1,5 +0,5 @@ | ||
![npm](https://flat.badgen.net/npm/v/react-timing-hooks) | ||
![minified](https://flat.badgen.net/bundlephobia/minzip/react-timing-hooks) | ||
[![npm](https://flat.badgen.net/npm/v/react-timing-hooks)](https://www.npmjs.com/package/react-timing-hooks) | ||
[![minified](https://flat.badgen.net/bundlephobia/minzip/react-timing-hooks)](https://bundlephobia.com/result?p=react-timing-hooks) | ||
![types](https://flat.badgen.net/npm/types/react-timing-hooks) | ||
![checks](https://flat.badgen.net/github/checks/EricLambrecht/react-timing-hooks) | ||
[![checks](https://flat.badgen.net/github/checks/EricLambrecht/react-timing-hooks)](https://github.com/EricLambrecht/react-timing-hooks) | ||
@@ -31,6 +31,2 @@ # React Timing Hooks | ||
## Usage | ||
```bash | ||
npm i react-timing-hooks | ||
``` | ||
@@ -37,0 +33,0 @@ ```jsx harmony |
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
29876
18
385
123