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

An easy to use timer hook for React


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

timer-hook

Demo: https://codesandbox.io/s/timer-hook-example-ze88r

Usage

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

PropertyTypeDefault valueDescription
endTimenumbernullend time for the timer
initialTimenumber0starting value for the timer
intervalnumber1000the interval between each tick in milliseconds
onEndfunctioncallback function to run when timer is over
stepnumber1the value to change by each tick
typestring"INCREMENT""INCREMENT" or "DECREMENT"

Keywords

FAQs

Package last updated on 28 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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