Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

use-countdown

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-countdown

Countdown with react hooks

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
Maintainers
1
Weekly downloads
 
Created
Source

use-countdown

Installation

npm install --save use-countdown

Usage

  • useCountdown
    import React from 'react'
    import { useCountdown } from 'use-countdown'
    
    export const Countdown = () => {
      const ms = useCountdown({
        targetTime: new Date(2100, 08, 12).getTime(),
        interval: 1000, // default
      })
    
      return (
        <React.Fragment>
          <h1>Countdown</h1>
          <p>{ms}</p>
        </React.Fragment>
      )
    }
    
  • useFormattedCountdown
    import React from 'react'
    import { useFormattedCountdown } from 'use-countdown'
    
    export const Countdown = () => {
      const countdown = useFormattedCountdown({
        targetTime: new Date(2100, 08, 12).getTime(),
        interval: 1000,
        includeSymbols: ['d', 'h', 'm'],
        separator: ' - ',
      })
      // will return like: 99d - 10h - 16m
    
      return (
        <React.Fragment>
          <h1>Formatted Countdown</h1>
          <p>{countdown}</p>
        </React.Fragment>
      )
    }
    

Options

export interface CountdownOptions {
    readonly targetTime: number;
    readonly interval?: number;
}

export interface FormattedCountdownOptions extends CountdownOptions {
    readonly includeSymbols?: Array<'d' | 'h' | 'm' | 's'>;
    readonly separator?: string;
}

Keywords

FAQs

Package last updated on 19 Mar 2019

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