Socket
Socket
Sign inDemoInstall

timer-hook

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timer-hook - npm Package Compare versions

Comparing version 1.0.9 to 1.0.10

2

package.json
{
"name": "timer-hook",
"version": "1.0.9",
"version": "1.0.10",
"description": "An easy to use timer hook for React",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

# timer-hook
Demo: https://codesandbox.io/s/timer-hook-example-ze88r
## Usage
```javascript
import React from 'react';
import { useTimer } from 'timer-hook';
const App = () => {
const { time, start, pause, reset, isRunning } = useTimer();
return (
<>
<div>Time: {time}</div>
<div>
<button onClick={start}>{isRunning ? 'Start' : 'Running'}</button>
<button onClick={pause}>Pause</button>
<button onClick={reset}>Reset</button>
</div>
</>
);
};
```
## Configuration
All configurations are optional
| Property | Type | Default value | Description |
| ----------- | -------- | ------------- | -------------------------------------------------------------------------------------- |
| endTime | number | null | end time for the timer |
| initialTime | number | 0 | starting value for the timer |
| interval | number | 1000 | the interval between each tick in milliseconds |
| onEnd | function | | callback function to run when timer is over |
| step | number | 1 | the value to change by each tick |
| type | string | "INCREMENT" | "INCREMENT" or "DECREMENT" |
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